Solved

change img src with jQuery

Posted on 2011-02-28
3
1,965 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
[X]
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
  • 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Hello World !, Thanks : My Sincere thanks to @Michael Male who encouraged me to write an article on this in my  blog (http://scribblejava.wordpress.com). Introduction:       There are several technical issues a developer may face in his…
jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

632 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