Get div content inside (javascript code) using jquery or any way -


this question has answer here:

i trying #email div content insdie javascript code.

example:

<div id="email">useremail@gmail.com</div> 

i want print email address here

document.write('<img src="' + get_gravatar('email here', 150) + '" />'); 

thank much!

i suggest to not use document.write.

if understand you, using jquery:

(function($) //iief format {     $(function() //wait doc ready     {         var $img = $('<img></img>'); //create img tag using jquery         var email = $('#email').text().trim() //could .html() inner html         $img.attr('src', get_gravatar(email, 150) ) //add email src attribute of img tag          $('body').append($img); //change 'body' whatever want add to; append img tag document     } })(jquery); 

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -