How to make javascript created image a link -
hey there not fluent javascript , jquery. want replace div image when clicked on 1 div , make image clickable i.e. want add link image.
to using javascript
function replacecontentincontainer(id,content) { var container = document.getelementbyid(id); container.innerhtml = content; }
i calling javascript index.ctp file
<div id="vedio-image"> </div> <div class="title"> <a href="javascript:replacecontentincontainer('vedio-image', '<img width=\'480px\' height=\'220px\' src=\'<?php echo $this->webroot.'img/'.$count['news']['videoimage']; ?> \'/ >')"> <?php echo $count['news']['title'];?> </a> </div>
replacecontentincontainer working not able make image clickable. please can help.
you didn't write onclick
in <img>
tag, or not surround <img>
tag <a>
tag
change html code :
<div id="vedio-image"></div> <div class="title"> <a href="javascript:replacecontentincontainer('vedio-image', '<a href=\'http://example.com\'><img width=\'480px\' height=\'220px\' border=\'0\' src=\'<?php echo $this->webroot.'img/'.$count['news']['videoimage']; ?> \' /></a>')"> <?php echo $count['news']['title'];?></a> </div>
sidenote: added border="0"
avoid blue border appearing in ie.
Comments
Post a Comment