I am new to jQuery. I want to write the following HTML (along with the classes) using jQuery. How can I do this?
-
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>');
讨论(0)
-
$('<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!
讨论(0)
-
$('<div>').addClass('phnbr').append($('<div>').addClass('phtext').append('hi how are you, ').append($('<a>').attr({ target: '_blank', href: 'http://www.xyc.com'}).text('click here.')));
讨论(0)