<a id="t-1">Details - 1</a>
<a id="t-2">Details - 2</a>
<a id="t-3">Details - 3</a>
并且有3个按钮
<input type="button" name="submit-1" id="submit-1">
<input type="button" name="submit-2" id="submit-2">
<input type="button" name="submit-3" id="submit-3">
现在,当我点击任何其他链接时,我需要更改按钮类型以提交
例如,如果我点击id为“t-1”,输入类型“submit-1”应该从按钮改为提交
如何使用jQuery实现这一目标?
答案 0 :(得分:0)
$("a[id^='t-']").click(function(){
var buttonId = this.id;
document.getElementById('submit-' + buttonId).setAttribute('type','submit');
});