i have a <div id="mainDIV">
which contains a <table>
within which <thead>
and <tbody>
tags are present.
Actually i am trying these selector
$("#mainDIV > tbody").on("click", function(){
alert("test");
}
so that whenever we click inside the <tbody>
, that alert should be displayed. But this is not working. Can anyone please suggest me solution for this.
I tried the below one but its not working...
$("#mainDIV tbody").on("click", function(){
alert("test");
}
This is my part of the code thats not working..
$("#ui-datepicker-div tbody").on("click", function(){
alert("test");
});
You should use white space instead of >
:
$("#mainDIV tbody").on("click", function(){
alert("test");
});
Descendant Selector ( "ancestor descendant"
) docs :
Description: Selects all elements that are descendants of a given ancestor.
Child Selector ( "parent > child"
) docs :
Description: Selects all direct child elements specified by "child" of elements specified by "parent".
$('#mainDIV tbody').click(function() {
alert("test");
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.