html - javascript - get img src -


if have img in index.html:

<script src="script/script.js" type="text/javascript"></script> <img id="imgb" src="picture/banner1.jpg" border="0"> 

then in separate file, such gallery.html, need src element of img in index.html.

i tried writing function:

function imgbbs(){     var x = document.getelementbyid('imgb').src;     document.getelementbyid('imgbb').src = x; } 

then try using in gallery.html:

<script src="script/script.js" type="text/javascript"></script> <body onload="imgbbs()">     <img id="imgbb" src="" border="0"> 

but doesn't seem working. how can src attribute of img in different file?

a way load partial part of index page using jquery this:

$( "#your_image_container_in_gallery.html" ).load( "index.html #imgb" ); 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -