如何使用jquery按名称获取元素? [英] how to get elements by name using jquery?

查看:69
本文介绍了如何使用jquery按名称获取元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不使用id或class的情况下使用jquery按名称获取html元素?有什么办法吗?

how to get html element by name using jquery without using id or class ? Is there any way to do that?

推荐答案

应该知道,给出的唯一正确答案是那些包含属性值引号(即引号)的答案.

It should be known that the only correct answers that have been given are the ones that included quotes around the attribute value, ie.

$("[name='value']")

这是一项强制性要求,必须在值周围加上引号,请参见: http://api.jquery.com/attribute-equals-selector/

It is a mandatory requirement to include quotes around the value, see: http://api.jquery.com/attribute-equals-selector/

如果您在引用nodeName或"tag"时使用名称",则只需按该字符串进行选择:

If you are using "name" in reference to the nodeName or "tag", then simply select by that string:

$("div")
$("a")
$("p")
$("input")
$("body")

这篇关于如何使用jquery按名称获取元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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