如何将HTML放入jQuery .text() [英] How to put HTML in jQuery .text()
本文介绍了如何将HTML放入jQuery .text()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找不到任何地方,部分原因是它的关键字很常见。
$('。pause_button') .text('< img src =../ imgs / icons / control_pause_blue.pngalt =简历/>简历');
它如何以HTML格式打印,而不是转换括号和撇号?
解决方案使用jQuery中的
.html
函数avaialble, .html()
。 例如:
$('div.demo-container')。html ('< p>所有新内容< em>您打赌!< / em>< / p>');
您的情况
$('。pause_button')。html('< img src =../ imgs / icons / control_pause_blue.png
alt =简历/>简历');
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');
这篇关于如何将HTML放入jQuery .text()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文