How can I get this image to change when I toggle some content?

Head out to http://brucegust.com/eResume/

In the upper right hand corner, there's a little downarrow button that you can click on that reveals some content. When you click it, the arrow changes to "up." I want to change it back to "down" when the user clicks on it again to minimize the expanded content.

How?

You can see where I started in my code with this:

$('#instructions').click(function(event){
		event.preventDefault();
		//$("#the_button").attr("src", "images/minimize_button.png");
		var src = $('#the_button').attr('src');
		if(src="images/expand_button.png")
		{
			$("#the_button").attr("src", "images/minimize_button.png");
		}
		else
		{
			$("#the_button").attr("src", "images/expand_button.png");
		}
		$('#instruction_row').slideToggle(300);
	});

Open in new window


I think I'm close, but I got stuck.

Thanks!
brucegustPHP DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
replace your whole code by the following one :
<script>
$(document).ready(function(e) {
	$('img[usemap]').rwdImageMaps();
	
	$('area').on('click', function() {
		//alert($(this).attr('alt') + ' clicked');
	});
	
	$('#instructions').click(function(event){
		event.preventDefault();
		$('#instruction_row').slideToggle(300, function() {
			var src = $("#instruction_row .col-xs-12").is(":visible") ?  "images/expand_button.png" : "images/minimize_button.png";
			$("#the_button").attr("src", src);
		});
	});
});
</script>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vish KTechnologistCommented:
Hello,
you have error in your condition thats why it is not working as expected. If you change it to two == signs, it will work fine.
if(src="images/expand_button.png") { 

Open in new window



I have modified your code to be little more stable.
$('#instructions').click(function(event) {
  event.preventDefault();
  $('#instruction_row').slideToggle(300, function() {
    if ($('#instruction_row').css('display') === 'block') {
      $('#the_button').attr('src', 'images/minimize_button.png');
    } else {
      $('#the_button').attr('src', 'images/expand_button.png');
    }
  });
});

Open in new window

0
brucegustPHP DeveloperAuthor Commented:
Vish!

I just realized I blew right past your contribution! So, sorry!

I'll ask one of the moderators to open up the question so I can honor you with some points.

Thanks!
0
Vish KTechnologistCommented:
Thanks bruce,
let me know if my contribution helped.
0
brucegustPHP DeveloperAuthor Commented:
I went with Leak's solution, but Vish - I'm taking notes and putting your solution into my "files" for future reference. Thanks both of you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.