But i am not getting the desired functionality of toggling. Please
help
Like Josh, I can't help much without seeing html, but I would suggest
using .show() and .hide() rather than .css('display',...).
FF uses (the more appropriate) display: table-row for <tr> elements,
so setting to display: block will most likely produce some funky
results.
So, change ...$($trId).css("display","");
to ...
$($trId).show();
And change ...
$($trId).css("display","none");
to ...
$($trId).hide();
Also, I wonder if this is working correctly:
var $trId = "#myTrId" + $("[EMAIL PROTECTED]'imgId']").index(this);
If you're using FF with Firebug, check what the value of $trId is by
adding this line after the one above (and then checking the console):
console.log($trId);
Otherwise, just use an alert:
alert($trId);
In what ways is it failing? Is it producing a JavaScript error?
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Dec 24, 2007, at 12:21 PM, Josh Nathanson wrote:
Try changing this:
$($trId).css("display","");
To this:
$($trId).css("display","block");
Don't know if that's the whole problem, kinda hard to tell without
seeing the html, but it's a start.
-- Josh
----- Original Message ----- From: "JQueryProgrammer" <[EMAIL PROTECTED]
>
To: "jQuery (English)" <jquery-en@googlegroups.com>
Sent: Monday, December 24, 2007 5:17 AM
Subject: [jQuery] Problem with toggle
I am facing an issue with the toogle API. I have a tr with dynamic
Id's as Id1, Id2 etc..... Within that tr I have many td's in which
one
td has an image which needs to be toggled to plus image and minus
image. That is when I click on the image, it should toggle between
plus and minus images. Also when the image is clicked another tr
should be displayed and hidden accordingly. That means a tr within a
tr and the outer tr has an image. I was trying to write the code as:
$("[EMAIL PROTECTED]'myImgId']").toggle(
function() {
var $trId = "#myTrId" + $("[EMAIL PROTECTED]'imgId']").index(this);
$($trId).css("display","");
$(this).attr("src","minus.jpg");
},
function() {
var $trId = "#myTrId" + $("[EMAIL PROTECTED]'imgId']").index(this);
$($trId).css("display","none");
$(this).attr("src","plus.jpg");
}
);
But i am not getting the desired functionality of toggling. Please
help