Is there a better, more jQuery-ish way of handling this image substitution?
var image = $(obj).children(\"img\");
if ($(image).attr(\"src\") == \"Images/TreeColl
You could do something like this
e.g
$(function()
{
$(obj)
.children("img")
.attr('src', swapImage );
});
function swapImage(){
return (
$(this).attr('src') == "Images/TreeCollapse.gif" ?
"Images/TreeExpand.gif" :
"Images/TreeCollapse.gif");
}
N.B in your question you do $(image) multiple times. Its better to cache the lookup in a var e.g var $image=$(obj).children("img"); then use the $image from there on in.