Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

change img src with jQuery

Posted on 2011-02-28
3
1,910 Views
Last Modified: 2012-05-11
I don't understand why I can't chnage the image by chaning the src. What am I doing wrong?


<td id="TagLine" colspan="2" align="right"><?php echo '<img id="DoYouMeasureUp" src="'.BASEURL .$taglinefile .'" alt="'.$_SESSION['lang']['tagline'] .'" width="296" height="44"/>'?>
	</td>

Open in new window


I added this in a jQuery and tried all three different ways to define path to file
	$("#sLangSelect").live('change', function(){
		
		var myLanguage = $(this).val();
		//runReport();
		//$("#headerSection").load('/aaMain/header.php');
		switch (myLanguage)
		{
			case '1':
				
				$('img').attr('src') = '/images/do-you-measure-up-english.gif';
	
				break;
			case '2':
				
				$('#DoYouMeasureUp').attr('src')= "images/do-you-measure-up-french.gif";
			
				break;
			case '3':
				
				$('#DoYouMeasureUp').attr('src')= "http://dev.secure.emetrixsystems.com/images/do-you-measure-up-spanish.gif";
				
				break;
		}
		
		
	/*	var rt = $.ajax({
	   type: "POST",
	   url: "/aaMain/header.php?ulang="+$(this).val(),
	   //data: $("form[name=filters]").serialize(),
	   success: function(msg){
$("#headerSection").html(msg); }
});*/

		
});
       

Open in new window

0
Comment
Question by:gbeaulac
  • 2
3 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 34998131
For example :

$('img').attr('src', '/images/do-you-measure-up-english.gif');

Open in new window


and not :

$('img').attr('src') = '/images/do-you-measure-up-english.gif';

Open in new window

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 34998147
with select the image by its id and not it tag, use the # :


$
('#imgId').attr('src', '/images/do-you-measure-up-english.gif');

Open in new window

0
 

Author Closing Comment

by:gbeaulac
ID: 34998180
You are the Man!!!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
RadGrid not rebinding after detailsview update event? 2 89
Some high points and examples of what's great about Facebook React? 5 177
Python - desktop use 1 43
Ajax and PHP 4 29
Today I am discussing AJAX problems in IE7 and I bet this will helps many guys out here who have problems with AJAX work. Lets start with the discovery of problem and then we will talk about its different solutions. My last two projects included …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question