Reputation: 117
I am trying to hide "arrow_o" on click of "thead" but it is not working. Does jquerys "children" not work in tables?
html
<thead class="thead">
<tr>
<th>
<div class="arrow_o"></div>
</th>
</tr>
</thead>
js
$(document).ready(function() {
$('.thead').click(function() {
$(this).children('.arrow_o').hide();
});
});
Upvotes: 1
Views: 1160
Reputation: 6127
The .children() method differs from .find() in that .children() only travels a single level down the DOM tree while .find() can traverse down multiple levels to select descendant elements (grandchildren, etc.) as well.
Use .find() instead.
Upvotes: 2
Reputation: 40582
The .children() method differs from .find() in that .children() only travels a single level down the DOM tree while .find() can traverse down multiple levels to select descendant elements (grandchildren, etc.) as well.
So this:
$(document).ready(function() {
$('.thead').click(function() {
$(this).find('.arrow_o').hide();
});
});
Upvotes: 5
Reputation: 79850
Try $('.arrow_o', this).hide();
which basically sets the context where the arrow_o
should be located.
Full Code:
$(document).ready(function() {
$('.thead').click(function() {
$('.arrow_o', this).hide();
});
});
Upvotes: 2