使用jQuery禁用多个表单之一中的按钮
我有很多这样的表格:使用jQuery禁用多个表单之一中的按钮,jquery,Jquery,我有很多这样的表格: <form class="some-name"> <input type="hidden" name="bill" value"flower" /> <button value="0">Yes</button> <button value="1">No</button> <button value="2">No</button> </form
<form class="some-name">
<input type="hidden" name="bill" value"flower" />
<button value="0">Yes</button>
<button value="1">No</button>
<button value="2">No</button>
</form>
<form class="some-name">
<input type="hidden" name="ben" value"men" />
<button value="0">Yes</button>
<button value="1">No</button>
<button value="2">No</button>
</form>
还尝试:
$(document).on("click", ".some-name button", function(){
$($(this)).parent("button").attr("disabled", true);
});
但两个都不走运
$(document).on("click", ".some-name button", function(){
$(this) // currently clicked button
.siblings("button") // all neighbor of clicked button
.prop("disabled", true); // set disabled
});
相关参考文献:
相关参考文献:
这不是有效的jQuery。你想要的是:
$(this).parent().find('button')
这不是有效的jQuery。你想要的是:
$(this).parent().find('button')
试试这个:
$(document).on("click", ".some-name button", function(){
$(this).parent('form').children("button").attr("disabled", true);
});
以下是您的建议尝试一下:
$(document).on("click", ".some-name button", function(){
$(this).parent('form').children("button").attr("disabled", true);
});
这是为什么你有$$this???@Christopherkeney在编辑时把括号弄乱了为什么你有$$this???@Christopherkeney在编辑时把括号弄乱了