【问题标题】:What is the vanilla javascript version of this jQuery?这个 jQuery 的原生 javascript 版本是什么?
【发布时间】:2018-12-22 02:21:49
【问题描述】:

我有这个 jQuery 用于处理表单中的许多单选按钮,但我想知道如何用 Vanilla Javascript 编写它。

const checked_radios = $('input[type="radio"]:checked');

谢谢。

我知道还有其他帖子解释了 jQuery 如何在幕后工作,但具体案例可能不仅对我有用,对其他人也有用。

【问题讨论】:

标签: javascript jquery


【解决方案1】:

你可以使用querySelectorAll:

const checked_radios = document.querySelectorAll('input[type="radio"]:checked');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-07
    • 1970-01-01
    • 2013-10-11
    • 1970-01-01
    • 1970-01-01
    • 2018-12-24
    • 2013-02-03
    相关资源
    最近更新 更多