javascript jquery单选按钮单击 [英] javascript jquery radio button click
本文介绍了javascript jquery单选按钮单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个单选按钮和jquery正在运行。
I have 2 radio buttons and jquery running.
<input type="radio" name="lom" value="1" checked> first
<input type="radio" name="lom" value="2"> second
现在,通过一个按钮我可以设置onClick来运行一个功能。当我点击其中一个时,单选按钮运行功能的方法是什么?
Now, with a button I can set onClick to run a function. What is the way to make radio buttons run a function when I click on one of them?
推荐答案
你可以使用 .change
为你想要的东西
You can use .change
for what you want
$("input[@name='lom']").change(function(){
// Do something interesting here
});
自jQuery 1.3起
你不再需要'@'。正确的选择方式是:
you no longer need the '@'. Correct way to select is:
$("input[name='lom']")
这篇关于javascript jquery单选按钮单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文