Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
Leave the ids on the <tr> and use a common class for the <div> nested within it. Put an ID on the table that contains the <tr>s.
Code:
$(document).ready(function() {
$("#mytableid tr").hover(function() {
$("#" + this.id + " div.my-class").slideDown(400);
}, function() {
$("#" + this.id + " div.my-class").slideUp(400);
});
});
Or, if it is the only <div> that is the child of the <tr> you could forget the class altogether, and just target it as $("#" + this.id + " div")
***EDIT***
btw, after a second glance at your code, I see you need to change the "inprog" variable as a callback to the slideUp/slideDown when hovering off, because the way you're doing it, it will be executed before the animation is complete. Also, you need to nest the if() inside the first hover function, not outside the event. So:
Code:
$(document).ready(function() {
var inprog = 0;
$("tr#unique1").hover(function() {
if (inprog == 0) {
inprog = 1;
$("#msgtxt1").slideDown(400);
}
}, function() {
$("#msgtxt1").slideUp(400, function() {inprog = 0;});
});
});
Also, you dropped some quotation marks in your example, which made the code invalid.
You'll have to combine the two ideas I gave you, because on the second example, all I did was edit the code you gave. Note that I put the variable declaration "inprog" inside of the $(document).ready(), which I think is better, since it stays local to that namespace.
Last edited by wayfarer07; 03-12-2009 at 02:00 PM..
|