“window.addeventListener” Code-Antworten

JavaScript Onclick Event Hörer

document.getElementById("myBtn").addEventListener("click", function() {
  alert("Hello World!");
});
Batman

JavaScript AddEventListener

var element = document.getElementById("#id");
element.addEventListener('click', function(){
	console.log("click");
});
Innocent Ibis

JS AddEventListener

var element=document.getElementById("some_id");
var listener=element.addEventListener('click',function(event){                          
            
 }); 
Grepper

JavaScript -Passparameter zum Ereignishörer

var someEventHander=function(){
	console.log(event,param1,param2);
}
//add listener
document.getElementById("someid").addEventListener('click',someEventHander.bind(event,param1,param2));
Grepper

window.addeventListener

window.addEventListener("scroll", function(){
   console.log('scrolling');
});
Hossam Rashad

AddEventListener JavaScript

// The anwer of Innocent Ibis is wrong!!
// It should not have a # for the ID seens we are using getElementById
var element = document.getElementById("id");
element.addEventListener('click', function(){
	console.log("click");
});
Karamolegkos

Ähnliche Antworten wie “window.addeventListener”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen