我有2个文本字段和2个调用相同功能的按钮。
<input type="text" id="value1"/>
<input type="button" value="Get value" id="getvalue"/><br>
<input type="text" id="value2"/>
<input type="button" value="Get value" id="getvalue"/><br>
$('#getvalue').click(function(){
recording one value at a time
});
如何记录来自同一函数的每个单独的值。任何建议都将非常欢迎。
谢谢。
ID应该是唯一的。
您为什么不使用这样的代码。
<input type="text" id="value1"/>
<input type="button" value="Get value" class="getvalue" id="btn1" /><br>
<input type="text" id="value2"/>
<input type="button" value="Get value" class="getvalue" id="btn2"/><br>
$('input.getvalue').click(function(){
if (this.id == "btn1") {
}
if (this.id == "btn2") {
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句