How to put HTML in jQuery .text()
I couldn't find this anywhere, partly because its keywords are pretty common.
$('.pause_button').text('<img src="../imgs/icons/control_pause_blue.png" alt="Resume"开发者_开发技巧 /> Resume');
How can this be printed as HTML and not convert the brackets and apostrophes?
Make use of the .html
function avaialble in jQuery, .html()
.
For example:
$('div.demo-container').html('<p>All new content. <em>You bet!</em></p>');
In your case
$('.pause_button').html('<img src="../imgs/icons/control_pause_blue.png"
alt="Resume" /> Resume');
.text()
actually escapes all HTML specific characters, .html()
doesn't.
Use .html()
$('.pause_button').html('<img src="../imgs/icons/control_pause_blue.png" alt="Resume" /> Resume');
use .html()
$('.pause_button').html('<img src="../imgs/icons/control_pause_blue.png" alt="Resume" /> Resume');
You should use .html();
.
Use .html()
instead of .text()
.
精彩评论