jquery - how to get value from div and place it within img tag src in php -
value coming table on clicking row :
<script> var link_base = "<?php echo bloginfo('template_url').'/savelabel/'; ?>" ; var img_name = $('#imgdiv').text(); $('#imgid').attr('src', link_base + img_name); </script> <div class="bx2"> <img id="imgid" alt="" class="imgsty" /> </div>
selected filename showing in div :
<div id="txtdiv"></div>
and within html, there image tag, in want pass value of div
(ie name of image file) src=""
within img tag.
the code trying achieve shown below :
<script> var link_base = "<?php echo bloginfo('template_url').'/savelabel/'; ?>" ; var img_name = $('#imgdiv').text(); $('#imgid').attr('src', link_base + img_name); </script> <div class="bx2"> <img id="imgid" alt="" class="imgsty" /> </div>
wrap script in $(document).ready(function(){...your code ...});
, ensure dom structure ready process image in case ready change src
<script> $(document).ready(function(){ var link_base = "<?php echo bloginfo('template_url').'/savelabel/'; ?>" ; var img_name = $('#imgdiv').text(); $('#imgid').attr('src', link_base + img_name); }); </script>
Comments
Post a Comment