On Nov 18, 7:25 am, Denis Caggiano <denisribe...@gmail.com> wrote: > I'm defined an ID to my table (ID = "tb") that have my report, and > trying to code like this: > > $("#tb > a").click(function() { > alert('Test'); > });
"#tb > a" points to link elements that are the direct children of the element with id "tb". "#tb a" points to link elments contained anywhere inside the element with id "tb". In other words, your selector will not catch the <a> tag in this markup: <table id"tb"> <tbody> <tr> <td>Search</td> <td><a href="http://google.com">Google</a></td> </tr> </tbody> </table> This one would: "#tb > tbody > tr > td > a", but this is much simpler: "#tb a". > In other words, how can I define that all <a> in my table triggers an > event when clicked? The other thing to make sure you're doing is to call your code once the DOM is loaded, either in the bottom of the page or inside a document.ready block, such as: $(document).ready(function() { $("#tb > a").click(function() { alert('Test'); }); }); Cheers, -- Scott