[Refresh:] This question is related to: what does jQuery click () do?
Click click jQuery () did not click?
The following code:
<div id="oneDiv">
some content
</div>
<p>
<a href="http://www.google.com" id="clickme">Click Me</a>
</p>
[ ... ]
onload = function() {
$('#clickme').click(function() {
$('#oneDiv').css({border: '6px dotted #07d'})
});
document.getElementById('clickme').onclick = function() {
document.getElementById('oneDiv').style.color = 'green';
}
document.getElementById('clickme').addEventListener("click", function() {
document.getElementById('oneDiv').style.background = '#ffc';
}, false);
setTimeout(function() {
$('#clickme').click();
}, 3000);
}
If you click on the link, the browser will be
1) change the border to 6px with a dotted blue
2) change the text inside the div so that it is green
3) change the background of the div to offwhite
4) go to www.google.com
but if you wait and enable the setTimeout () function, it will only do
$('#clickme').click(function() { })
onclick = function() { ... }
he will not do addEventListenerone, and he will not follow the link. (IE 8 doesn't allow the addEventListenerway)
? jQuery click(), , ('click'), , DOM 0?