Skip to content Skip to sidebar Skip to footer

Getting Image Src Name Javascript

I would like to have album_name = Precious How do I get that?

Solution 1:

$(function() {
    $(".ps_img").click(function(){
       var album = $(this).find("img").attr("src").split("/")[1];
       alert(album);
    });

});

Solution 2:

This should do the trick:

$ps_albums.children('div').bind('click',function(){
  var album_name  = $(this).find('img').attr('src').split('/')[1];
});

Solution 3:

Try this:

$(function() {
  $('#ps_albums .ps_album').click(function() {
    var $elem = $(this);
    var $img = $elem.find('img');
    var album_name = $img.attr('src').split('/')[1];
  });
});

Post a Comment for "Getting Image Src Name Javascript"