2 回答
TA贡献1828条经验 获得超4个赞
用于.next()引用下一个元素。
$(function() {
$('#container').on('click', '.btn-checkout', function(e) {
$(this).html('proccesing order');
$(this).attr("disabled", true);
$(this).next("button").attr("disabled", true);
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form method="POST">
<div id="container">
<h3>this area is alone</h3>
<button type="button" class="btn-checkout">button1</button>
<button type="button" class='button2'>button2</button>
<h3>this area is alone</h3>
<button type="button" class="btn-checkout">button3</button>
<button type="button" class="button2">button4</button>
</form>
TA贡献1831条经验 获得超9个赞
那 ??
const myForm = document.forms.container
myForm.addEventListener('click', myFunction, false)
function myFunction(evt)
{
// ignore other cases:
if (!evt.target.matches('button.btn-checkout')) return
evt.target.nextElementSibling.disabled = true
}
// disable submit
myForm.onsubmit =evt=>evt.preventDefault()
<form method="POST" name="container">
<h3>this area is alone</h3>
<button type="button" class="btn-checkout">button1</button>
<button type="button" class='button2'>button2</button>
<h3>this area is alone</h3>
<button type="button" class="btn-checkout">button3</button>
<button type="button" class="button2">button4</button>
</form>
添加回答
举报