开发者

change from button to submit

开发者 https://www.devze.com 2023-02-28 18:30 出处:网络
<a id=\"t-1\">Details - 1</a> <a id=\"t-2\">Details - 2<开发者_开发知识库/a>
<a id="t-1">Details - 1</a>
<a id="t-2">Details - 2<开发者_开发知识库/a>
<a id="t-3">Details - 3</a>

and there are 3 buttons

<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">

Now when I click any other the link, I need to change type of button to submit

For example, if I click with id "t-1", the input type of "submit-1" should change from button to submit

How can I achieve this using jQuery?


$("a[id^='t-']").click(function(){
   var buttonId = this.id;
   document.getElementById('submit-' + buttonId).setAttribute('type','submit');
});
0

精彩评论

暂无评论...
验证码 换一张
取 消