Side navigation
#7483 closed bug (invalid)
Opened November 12, 2010 09:51AM UTC
Closed November 12, 2010 02:26PM UTC
triggle() in $(document).ready() can't work
Reported by: | anonymous | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.5 |
Component: | unfiled | Version: | 1.4.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 TransitionalEN" "http:www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script type="text/javascript" src="jquery-1.4.4.min.js"></script>
<script type="text/javascript">
$(function(){
$("#ok").trigger("click");
$("#ok").click(function(){
alert("OK!");
});
});
</script>
<title>无标题文档</title>
</head>
<body>
<input type="button" id="ok" value="ok" />
</body>
</html>
in the code , this line $("#ok").trigger("click"); never execute.
This can't work. You call
trigger()
before you have bound the click handler. You need to revert the order if you want this to work.See this test case