+ 2
Functions and access
I have two questions: 1.How can i access an element that has a particular function name in javascript? 2.How can i know if a particular event attribute has been triggered a specific number of times in JavaScript?
7 Réponses
+ 1
For number of events just define a var a = 0 ;
Define a function on that event such that onevent
a++;
console.log (a) ;
+ 3
Ok i get it thank you
+ 3
For q1:
I mean how can i know if an element has an event attribute
For example:
<button onclick="show()" id="b" >:
How can i know if the button has a particular function name as its event attribute
+ 2
You didnt get me:
I mean how can i know the number of times an event has been triggered
+ 2
Ok thank you
+ 1
Will you clear q1 more plz.
+ 1
Var btn = document.getElementById("btn") ;
console.log(btn.getAttribute("onclick")) ;
It will return the value of attribute value i.e. function name