jQuery通过单击按钮启用和禁用文本框 [英] jQuery to enable and disable textbox with button on click
本文介绍了jQuery通过单击按钮启用和禁用文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我第一次单击按钮时,我希望启用textbox1,但禁用textbox2和textbox3,然后当我第二次单击按钮时,则启用textbox2,并且textbox11&禁用了textbox3,最后,当我第三次单击该按钮时,启用了textbox3,禁用了textbox1和textbox2.请帮助我..谢谢
When I click the button the first time, I would like textbox1 to be enabled, but textbox2 and textbox3 disabled, then when I click the button for the second time, textbox2 is enabled and textbox11 & textbox3 are disabled, and lastly when I click the button for the third time, textbox3 is enabled and textbox1 and textbox2 are disabled. Please help me.. Thank you
我已经尝试过了,我需要一个这样的jQuery脚本:
I have tried this, I need a jQuery script of this body:
<input type="text" name="text1" id="txt">
<input type="text" name="text2" id="txt2">
<input type="text" name="text3" id="txt3">
<input type="button" value="edit" name="button1" id="btn">
推荐答案
像波纹管一样
var count = 0;
$('#btn').click(function(){
count = count%3;
$('input[type="text"').attr('disabled',true).eq(count++).attr('disabled',false);
})
在第四次单击时,它将再次启用第一次输入.
On fourth click it will again enable first input.
这篇关于jQuery通过单击按钮启用和禁用文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文