开发者

td.click doesn't fire in jQuery

开发者 https://www.devze.com 2023-01-28 09:07 出处:网络
I have this table: <table> <tr class=\"tools\"> <td id=\"dataMenuIte开发者_如何转开发m\">

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消