td.click doesn't fire in jQuery
I have this table:
<table>
<tr class="tools">
<td id="dataMenuIte开发者_如何转开发m">
<img src="./view/images/database.png" /><br />
Data</td>
<td>...
And this jQuery-Source:
$('#dataMenuItem').click(function() {
alert('Handler for .click() called.');
});
Why doesn't it work?
In my testing, it does.
http://jsfiddle.net/HTxf2/
Tested in OSX (Chrome, Firefox) and Win (IE8)
Works here. See example. Have you tried to validate your HTML to make sure there are no issues there?
Oh, and are you applying the click handler within a domready event? jQuery provides a shortcut for it like so:
$(function() {
// Code to run when DOM is ready.
$('#dataMenuItem').click(function() {
alert('Handler for .click() called.');
});
});
Worked for me...
DO you have it in a
$(document).ready(function() {
block?
精彩评论