By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,982 Members | 1,955 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,982 IT Pros & Developers. It's quick & easy.

Jquery concatenation ?

gautamz07
P: 26
Expand|Select|Wrap|Line Numbers
  1. $('#gallery a').click(function(evt){
  2. evt.preventDefault();
  3. var imgPath = $(this).attr('href');
  4. var oldImage = $('#photo img');
  5. var newImage = $('<img src="' + imgPath + '">');
  6. newImage.hide();
  7. $('#photo').prepend(newImage);
  8. newImage.fadeIn(1000);
  9. oldImage.fadeOut(1000,function(){
  10.     $(this).remove();
  11.     }); //end Fadeout
  12.     });//end click    
  13.     $('#gallery a:first').click();
  14. }); // end ready
  15.  
How does the concatination on line 5 really work and what is it really doing , i understand that its appending 'imagePath' .. but how exactly is it doing it ? and what are all this " ' for , i mean so many of them
Apr 21 '14 #1
Share this Question
Share on Google+
4 Replies


Dormilich
Expert Mod 5K+
P: 8,639
and what are all this " ' for , i mean so many of them
attribute values should be quoted and must be quoted if the attribute value contains whitespace. hence the need to put quote marks inside the quote mark delimited strings.

i understand that its appending 'imagePath' .. but how exactly is it doing it ?
plain old string concatenation?
Apr 21 '14 #2

gautamz07
P: 26
thank you sir , but i still did't understand what exactly is the single quotation for and the double quotation for ! even though u say its the same old concatination !!!
Apr 21 '14 #3

Dormilich
Expert Mod 5K+
P: 8,639
hm, let me put it this way: how would you print a quote mark?
Apr 21 '14 #4

gautamz07
P: 26
in javascript if i have to print out a string along with a value , u concatinate it like this :

var a= 3;
console.log("the value of a is " + a + "and you will see this printed to the console");
Apr 22 '14 #5

Post your reply

Sign in to post your reply or Sign up for a free account.