嘿我试图下面让我的jQuery代码的工作:jQuery的追加与图像的HTML然后将其删除不显示
function submitContactUs() {
if ($('#cf-name-txt').val() == '' || $('#cf-name-txt').val().charAt(0) == '*') {
$('#cf-name-txt').append("<img src=\"img/attention.png\" width=\"16\" height=\"16\" style=\"position:absolute; left: -7px; top: 7px;\" />");
}
}
和HTML代码是这样的:
<div id="contactus-name">
<input type="text" id="cf-name-txt" style="width: 200px;" class="formBoxesContact" value="*Your Name">
</div>
它将图像添加到上面的html代码的末尾,但它不显示?它看起来像这样的萤火:
我在做什么,以使其不显示?
真棒......它让我如何停止生成图像每次我按下按钮时提交...? – StealthRT
添加一个if条件来检查图像,然后添加它..检查编辑 –
这似乎并不工作...无论如何保持添加 – StealthRT