Jquery concatenation ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gautamz07
    New Member
    • Sep 2013
    • 26

    Jquery concatenation ?

    Code:
    $('#gallery a').click(function(evt){
    evt.preventDefault();
    var imgPath = $(this).attr('href');
    var oldImage = $('#photo img');
    var newImage = $('<img src="' + imgPath + '">');
    newImage.hide();
    $('#photo').prepend(newImage);
    newImage.fadeIn(1000);
    oldImage.fadeOut(1000,function(){
    	$(this).remove();
    	}); //end Fadeout
    	});//end click	
    	$('#gallery a:first').click();
    }); // end ready
    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
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    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?

    Comment

    • gautamz07
      New Member
      • Sep 2013
      • 26

      #3
      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 !!!

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        hm, let me put it this way: how would you print a quote mark?

        Comment

        • gautamz07
          New Member
          • Sep 2013
          • 26

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

          var a= 3;
          console.log("th e value of a is " + a + "and you will see this printed to the console");

          Comment

          Working...