使用 jquery 获取 Json/Enum 值

发布于 2024-12-16 01:07:27 字数 297 浏览 2 评论 0原文

我目前拥有的:

我基于传递给函数的选项构建了 html 以制作复选框列表。 http://jsfiddle.net/dan_vitch/NE5LB/2/

我需要什么:

我需要确定用户选择了哪个框(目前具有正确值的警报就可以了)。 我用按位格式设置了列表,但过去并没有对此做太多事情。

这可能是我提供的代码太少而要求的回报太多的情况。如果这是真的,请告诉我,我将努力提供更多代码。

What I currently have:

I built html based off options passed into a function to make a list of checkboxes.
http://jsfiddle.net/dan_vitch/NE5LB/2/

What I need:

I need to determine which box(es) were selected by the user(an alert with correct value would be fine for now).
I set up my list with bitwise format in mind, but havent done much with that in the past.

This maybe a case of me providing too little in terms of code and asking for too much in return. If that is true let me know and I will work on providing more code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

两个我 2024-12-23 01:07:27

使用 选中选择器 例如:

$(function() {
  $('input[type="button"]').click(function() {
    $('input[type="checkbox"]:checked').each(function(){
      alert(this.id);
    });
  });
});

参见 此处 获取更新的 jsFiddle

Use the checked selector eg:

$(function() {
  $('input[type="button"]').click(function() {
    $('input[type="checkbox"]:checked').each(function(){
      alert(this.id);
    });
  });
});

See here for your updated jsFiddle

素衣风尘叹 2024-12-23 01:07:27

在 jQuery 1.7+ 中

isChecked = $(selector).prop('checked');

在 jQuery < 1.7

isChecked = $(selector).is(':checked');

In jQuery 1.7+

isChecked = $(selector).prop('checked');

In jQuery < 1.7

isChecked = $(selector).is(':checked');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文