php - get background image of tag using dom -
using dom, want show image in new html page <a>
tag via id mentioned..
<a class="lazy clogo" id="newphoto0" href="javascript:;" title="abc" onclick="opengall('phouter', '0612px612.x612.100906141758.c1u8', 'newphoto0');" data-original="http://content4.jdmagicbox.com/patna/u8/0612px612.x612.100906141758.c1u8/catalogue/10729ad97cafdc32d7957a5729aefb17.jpg" style="background: url(http://content4.jdmagicbox.com/patna/u8/0612px612.x612.100906141758.c1u8/catalogue/10729ad97cafdc32d7957a5729aefb17.jpg) 50% 50% / cover no-repeat;"><span class="rghtimgarw"></span></a> <a class="lazy clogo" id="newphoto1" href="javascript:;" title="xyz" onclick="opengall('phouter', '0612px612.x612.130831165451.v7j7', 'newphoto2');" data-original="http://content2.jdmagicbox.com/patna/j7/0612px612.x612.130831165451.v7j7/catalogue/c2e023156401eedfa089b18d9595f623.gif" style="background: url(http://content2.jdmagicbox.com/patna/j7/0612px612.x612.130831165451.v7j7/catalogue/c2e023156401eedfa089b18d9595f623.gif) 50% 50% / cover no-repeat;"><span class="rghtimgarw"></span></a>
i tried :
$picks=$dom-> getelementbyid("newphoto".$i)->getattribute('style'); $photo=$picks->nodevalue; echo $photo;
but not working because image url mentioned in inline css..!
in more details : have html page want capture image using tag id. i'm not sure how capture image url , echo image using getvaluebyid?
you can use .css()
background image value along .replace()
filter out other part:
$('#newphoto0').css('background-image').replace('url(','').replace(')','');
and
$('#newphoto1').css('background-image').replace('url(','').replace(')','');
update: urls in array
$(".lazy.clogo").map(function(){ return $(this).css('background-image').replace('url(','').replace(')',''); }).get();
Comments
Post a Comment