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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -