如果我有5個輸入框,類爲.inputBox,那麼我的jquery函數會在每個.inputBox行後面添加這些標記5次。這是爲什麼?jquery。每個函數
我只想在每個.inputBox之後插入一次這些標記。
任何人都知道該怎麼做?
function addImages() {
$(".inputBox").each(function() {
$('.inputBox').after("<img src=\"Images/thumbs_up_48.png\" class=\"thumbV\" id=\"up\" />");
$('.inputBox').after("<img src=\"Images/thumbs_down_48.png\" class=\"thumbV\" id=\"down\" />");
});
}
的HTML
<label for="FirstName">First Name</label>
<input type="text" class="inputBox" name="FirstName" title="First Name Here" id="firstName" />
沒有答案在我的其他帖子中工作。我找到了.each函數並嘗試了這一點,並且您的答案奏效了。謝謝! – Catfish 2010-02-02 02:00:21