我有这个代码:
JavaScript/jQuery:
$('#eform input').each(function() {
if (this.className.indexOf('required') != -1) {
$(this).closest('.rowElem').find('label').text(function(_, txt) {
return '*' + txt
});
}
});
我怎样才能返回红色的星号??
最佳答案
return '<span style="color:red">*</span>' + txt
并使用.html()
代替.text()
关于javascript - jQuery text() 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18920578/