我做了一個小jquery腳本來檢查輸入框的值是否大於5。但我有2個標籤和一個id,只有其中一個有效。在jQuery中使用多個ID
<div id="register">
<form id="register">
<input id="first" type="text" /> <a id="first" ></a> <br />
<input id="second" type="text" /> <a id="second" ></a>
</form>
$('input').keyup(function(){
if($(this).val().length<5)
{
$('a.first').text("Please fill");
}
if($(this).val().length<5){
$('a.second').text("Please fill");
}
});
但只顯示第一<a id="first"></a>
標籤。第二個標籤不可見
你不應該有兩個同名的ID。 – MoDFoX 2010-08-29 17:30:43