Skip to content

tiger986/automaticTriggerEvent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

An event that automatically triggers an element

JS code

//JQ method
$(function(){		
    $(".d1").click(function(){
	alert("d1's click events");
    });	
    $(".d1").trigger("click");			
})
	
//JS method
var div2 = document.getElementById("div2");
div2.onclick = function(){
    alert("d2's click events")
}	
if(document.all){//IE
    div2.click();
}else {//Other browsers
    var e = document.createEvent("MouseEvents");
    e.initEvent("click", true, true);
    div2.dispatchEvent(e);
}

About

An event that automatically triggers an element

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages