click listener on by class name in javascript
var elements = document.getElementsByClassName("classname");
var myFunction = function() {
var attribute = this.getAttribute("data-myattribute");
alert(attribute);
};
for (var i = 0; i < elements.length; i++) {
elements[i].addEventListener('click', myFunction, false);
}
Also in JavaScript:
- attempt to invoke virtual method 'android.graphics.drawable.drawable react native
- vuejs my chart load before fetch data
- javascript transfer to another page
- react how to manipulate children
- toastify js
- javascript get url path
- clear timeout in function js
- how reliable is js hasownproperty
- how to program an array in js
- convert integer month to string month react native
- not equal to in js
- Cannot assign to read only property 'value' of object '[object Object]
- aes 256 nodejs
- array map order by timestamp reactjs
- import svg react
- save or update mongoose
- oneerror javascript image
- ngmodel div angular 7
- use property in angular 8
- bcd full form in electronics
- enable disable click on div jquery
- discord bot javascript remove user data in array
- set node process production
- navigation react pass props