0

I need to check the status of the image in the img tag by using flag like imagestatus =1 in the following code

 echo '<a href="#" class="swap-menu"><img id="menu_image"  src="images/collapsed.gif" hspace = "2"/>'.$B->getAttribute('TITLE').'</a>'; 

here's the js file

$('.swap-menu').bind('click', function (event) {
    $('.sub-menu').find("+ ul").slideUp(1);
    $(this).find("+ ul").slideToggle("fast");
    $(this).find("img").attr('src', 'images/expanded.gif');
});
Greg
  • 2,163
  • 1
  • 21
  • 23
  • seeing your code in js file seems that you are using jQuery. so to update the `src` of `img` tag you can use jQuery toggle function. http://api.jquery.com/toggle/ – Murtaza Mar 30 '12 at 06:56

1 Answers1

1

I would add a class to the image when you are replacing the images src.

I'm assuming you are using jQuery, from your code.

See http://api.jquery.com/addClass/

Then you can use the hasClass method. See Determine if an element has a CSS class with jQuery

Community
  • 1
  • 1
simon
  • 73
  • 1
  • 8