Reputation: 6696
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<script src="jquery-1.6.2.js"></script>
<script>
$("#test").live("click", function(){
alert('');
});
$("#tbl").live("mouseover",function(){
$("#title").html('<input id="test" type="button" value="test button" />');
});
$("#tbl").live("mouseleave",function(){
$("#title").html('');
});
</script>
</head>
<body>
<table id='tbl' width="200" border="1">
<tr>
<td id="title"> </td>
</tr>
<tr>
<td id="content"> </td>
</tr>
</table>
</body>
</html>
$("#test").live("click"...) doesn't work, but if I change to mouseover it works. Any one can help?
Thanks, Cheng
Upvotes: 0
Views: 1149
Reputation: 21376
Use mouseenter
instessd of mouseover
,and as @davecoulter said put ";" end of the statments,
$("#test").live("click", function(){
alert();
});
$("#tbl").live("mouseenter",function(){
$("#title").html('<input id="test" type="button" value="test button" />');
});
$("#tbl").live("mouseleave",function(){
$("#title").html('');
});
here is the jsfiddle http://jsfiddle.net/Z2ZYs/1/
Upvotes: 1
Reputation: 5070
Try replace alert() to alert("Anything"); It's just work fine on my computer.
Upvotes: 0
Reputation: 4073
You just need to put a string in the alert('Something')
statement.
I have a working example here (jsFiddle)
Upvotes: 0
Reputation: 5800
Your problem is that you are using mouseover instead of mouseenter. I have a working example here.
Upvotes: 0
Reputation: 17586
the problem is alert()
does not work like this . just do this alert('');
Upvotes: 0
Reputation: 1826
Cheng:
Just a stab, but try putting ';' at the ends of your statements:
$("#test").live("click", function(){
alert();
});
$("#tbl").live("mouseover",function(){
$("#title").html('<input id="test" type="button" value="test button" />');
});
$("#tbl").live("mouseleave",function(){
$("#title").html('');
});
Upvotes: 0