Reputation: 1
I have a table cell and what I want is that if the user clicks on the table cell a div collapses (div is in another table cell).
$(function slideDown(id) {
$("getdiv"+id).fadeIn();
});
The table row (hover function):
<tr class="odd" id="div96" onhover="slideDown(96)"><td>ZZZn ZZZ</td></tr>
The table cell (needs to fade in/slide down):
<tr><td id="getdiv95" class="divinside" style="display: none;">Text</td></tr>
I'm sorry for my poor English.
Upvotes: 0
Views: 627
Reputation: 1485
You are doubling up the 'div' part.
var name = $(this).attr('id');
$("#" + name).slideDown();
The way you have it written now it would look like
$("#divdiv1")...
Instead of
$("#div1")...
Also, wrap all this in a $(document).ready(function(){}); so that it triggers the click binding after all the tr elements have loaded.
Upvotes: 1
Reputation: 78630
Slide down is a function, you must invoke it in order for it to be run:
$("#div" + name).slideDown();
Upvotes: 0