Solved

change img src with jQuery

Posted on 2011-02-28
3
1,902 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

823 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