我有添加行功能。我爲這些輸入框創建了動態ID。現在我想驗證。當我輸入部門名稱時會自動突出顯示關係字段(這是我的要求)。我嘗試過這個功能但失敗了。請幫助如何做這項工作。如何驗證在jQuery中使用ID添加行功能
<div class="col-sm-2">
<label for="" class="control-label"> Dependent Name(s)</label>
</div>
<div class="col-sm-3" style="margin-bottom:5px;">
<div class="form-group">
<input type="text" class="form-control name1" id="name1" onblur="getValue(this)" name="name1[]"/>
</div>
</div>
<div class="col-sm-offset-1 col-sm-2">
<label for="" class="control-label"> Relationship(s)</label>
</div>
<div class="col-sm-3">
<div class="form-group">
<input type="text" class="form-control relationship1" id="relationship1" name="relationship1[]" />
</div>
</diV>
<script>
function getValue(obj){
selectedid = obj.id;
selectedindexid = $(selectedid).closest('div').next('div').next('div').find('input:text').id;
}
</script>
這是功課嗎? ;) – angabriel
歡迎來到堆棧溢出!我已經修復了您的問題的展望(更改了問題描述和改進的代碼格式)。有關格式化的更多信息,請參閱編輯幫助(http://stackoverflow.com/editing-help)。如果需要識別特定問題,請編輯您遇到的特定錯誤消息。祝你好運! – marian0