[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:
$("img[@id^='myImgId']").toggle(
function() {
var $trId = "#myTrId" + $("img[@id^='imgId']").index(this);
$($trId).css("display","");
$(this).attr("src","minus.jpg");
},
function() {
var $trId = "#myTrId" + $("img[@id^='imgId']").index(this);
$($trId).css("display","none");
$(this).attr("src","plus.jpg");
}
);
But i am not getting the desired functionality of toggling. Please help