I have a dropdown that loads the data and there is a Add
button and when the add button is being triggered it will be disabled. It works in the first load, but when the dropdown is onchange
the disabled
button will be false
or not disabled. So how can I still disable the button when the dropdown is being changed. I have also a input field
to store the values of the button that has been clicked. Check http://jsfiddle.net/leonardeveloper/qy9u5/.
问问题
1479 次
2 回答
1
问题是,每次<select>
更改时您都会添加一个新元素。您每次都需要显示和隐藏相同的相应表格。您可以使用 jQuery 使用<option>
s 创建这些表。像这样:
$("#loads option").each(function(){
thisNumber = this.value;
$("#displays").append("<table data-table="+thisNumber+"><tr><td>"+thisNumber+"</td><td>"+thisNumber+"</td><td><button class='materialId' value='"+thisNumber+"'>Add</button></td></tr></table>");
$("#displays table").hide();
});
我们将表(在本例中为 2)附加到#displays
,然后隐藏它们。当我们更改<select>
现在时,我们会隐藏所有表格,并显示我们选择的表格,我已经用于data-table
此,但是有很多方法可以定位您的特定表格。
$(document).on("change","#loads", function(){
$("#displays table").hide();
$("#displays table[data-table="+this.value+"]").show();
});
于 2013-08-14T11:36:17.270 回答
0
于 2013-08-14T11:25:08.637 回答