I am new to jQuery. I want to write the following HTML (along with the classes) using jQuery. How can I do this?
<div class="phnbr">
<div class="phtext">hi how are you, <a target="_blank" href="http://www.xyz.com">click here.</a>
</div>
</div>
I am new to jQuery. I want to write the following HTML (along with the classes) using jQuery. How can I do this?
<div class="phnbr">
<div class="phtext">hi how are you, <a target="_blank" href="http://www.xyz.com">click here.</a>
</div>
</div>
$('<div class="phnbr"> \
<div class="phtext">hi how are you, <a target="_blank" href="http://www.xyz.com">click here.</a> \
</div> \
</div>'); // bang done!
append and appendTo is already confusing with 5+ tags in my opinion.Well you can just use append() or the other DOM Insertion Functions
$(document.body).append('<div class="phnbr"><div class="phtext">hi how are you, <a target="_blank" href="http://www.xyz.com">click here.</a></div></div>');