jQuery按钮集更改 [英] jQuery buttonset change

查看:93
本文介绍了jQuery按钮集更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是jQuery的新手,以为我会在应用程序中使用它的按钮集而不是某些单选按钮.此处的文档: http://jqueryui.com/demos/button/#radio

I'm new to jQuery and thought I would use its buttonset instead of some radio buttons on my application. Documentation here: http://jqueryui.com/demos/button/#radio

当按钮组的值更改时,如何向事件添加处理程序?

How do I add a handler to an event when the set of buttons changes value?

这是我尝试过的代码的片段:

Here is a snippet of the code I tried:

$('input.tod_quant').change(function() {
    alert('TEST');
});

然后在HTML中添加

<span id="tod_quant" class="buttonset">
        <input type="radio" id="tod_quant5" name="tod_quant" value="5" /><label for="tod_quant5">5-Minute</label>
        <input type="radio" id="tod_quant60" name="tod_quant" checked="checked" value="60" /><label for="tod_quant60">60-Minute</label>
        </span>

更改"事件从不触发.甚至还有变更事件吗?我怎样才能做到这一点?此外,是否有带有示例的文档? http://jqueryui.com 有很多示例,但我找不到一个显示任何事件的示例.我想我对jQuery的无知并不能完全解决问题.

The "change" event never fires. Is there even a change event? How can I do this? Furthermore, is there any documentation with an example? http://jqueryui.com has plenty of examples, and not a single one that I can find shows any events firing. I suppose my ignorance of jQuery isn't exactly helping the situation.

任何帮助将不胜感激.谢谢.

Any help would be most appreciated. Thank you.

推荐答案

哈!问题解决了.我整天都在骇客,它就在我眼前.

Ha! Problem solved. I've been hacking at this all day, and it was right in front of me.

我只需要更改选择元素的方式:

I just needed to change how I was selecting the element to this:

$('#tod_quant')

这篇关于jQuery按钮集更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆