jquery按名称选择

jQuery select by name or jQuery element selector allows us to find all HTML elements with the given tag name. You can do any sort of manipulation like animating or any other special effects after selecting the element and that change will take effect in all the elements of the same type or tag name. Earlier we learned using jQuery select by id and jQuery select by class.

jQuery按名称选择或jQuery元素选择器允许我们查找具有给定标签名称的所有HTML元素。 选择元素后,您可以进行任何类型的操作,例如动画设置或任何其他特殊效果,并且更改将在相同类型或标记名称的所有元素中生效。 之前我们学习过使用jQuery按id 选择和按类选择jQuery 。

jQuery按名称选择 (jQuery select by Name)

Here is the general syntax for using the jQuery select by name:

以下是使用jQuery按名称选择的一般语法:

$('tagName')

Any standard HTML elements like div, li, img,  p, em  etc could be used as the tagName. For example;

任何标准HTML元素(例如div,li,img,p,em等)都可以用作tagName 。 例如;

$('div') : This element selector will select all the div elements in the document.

$('div') :此元素选择器将选择文档中的所有div元素。

$('p') : This jquery select by name will consider all the paragraph elements in the document.

$('p') :按名称选择的此jquery将考虑文档中的所有段落元素。

If there are multiple <div> elements, you can change all the <div> elements in the document with this single expression $(‘div’).

如果有多个<div>元素,则可以使用单个表达式$('div')更改文档中的所有<div>元素。

You can hide, show or do any kind of manipulations on that <div> element. This is the most powerful advantage of using this jQuery selector.

您可以在该<div>元素上隐藏,显示或进行任何类型的操作。 这是使用此jQuery选择器的最大优势。

jQuery按名称选择示例 (jQuery select by Name Example)

This example demonstrates the use of jQuery select by name of tag, we will change the CSS style of the selected element.

此示例演示了使用jQuery通过标签名称进行选择,我们将更改所选元素CSS样式。

<html>
<head><title>jQuery selector By Name</title><style>div, span {width: 70px;height: 70px;float: left;padding: 12px;margin: 12px;background-color: #eee;}</style><script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body><div>DIV 1</div>
<span>SPAN 1 </span>
<div>DIV 2</div>
<span>SPAN 2 </span><script>
$( "div" ).css( "border", "5px solid green" );
</script>
</body>
</html>

In this example, you can see the selector $("div") is selected to change the CSS style. The only change in the code modified all the div elements uniformly. This is the strength of jQuery selector by name.

在此示例中,您可以看到选择器$("div")被选中以更改CSS样式。 代码中的唯一更改是统一修改了所有div元素。 这就是jQuery选择器的强项。

Below image shows the output produced by above HTML page.

下图显示了以上HTML页面产生的输出。

Therefore, in the case of enforcing a uniform behavior on html elements, you can use jQuery select by name in the code.

因此,在对html元素强制执行统一行为的情况下,可以在代码中使用jQuery按名称选择。

翻译自: https://www.journaldev.com/4552/jquery-select-name

jquery按名称选择

jquery按名称选择_jQuery按名称选择相关推荐

  1. jquery按名称选择_jQuery按类别选择

    jquery按名称选择 jQuery select by class name allows us to find a specific HTML element with the value of ...

  2. php表单复选传值,jQuery+SpringMVC中的复选框选择与传值实例_jquery

    下面我就为大家分享一篇jQuery+SpringMVC中的复选框选择与传值实例,具有很好的参考价值,希望对大家有所帮助. 一.checkbox选择 在jQuery中,选中checkbox通用的两种方式 ...

  3. php与mysql列表_PHP+Mysql+jQuery实现的查询和列表框选择

    本篇文章主要介绍PHP+Mysql+jQuery实现的查询和列表框选择,感兴趣的朋友参考下,希望对大家有所帮助. 本文讲解如何通过ajax查询mysql数据,并将返回的数据显示在待选列表中,再通过选择 ...

  4. jquery插件课程1 幻灯片、城市选择、日期时间选择、拖放、方向拖动插件

    jquery插件课程1  幻灯片.城市选择.日期时间选择.拖放.方向拖动插件 一.总结 一句话总结:都是jquery插件,都还比较小,参数(配置参数.数据)一般都是通过json传递. 1.插件配置数据 ...

  5. treeselect 如何选中多个_转pdf后出现word没有的形状——对象选择窗格(同时选择多个形状、图形)...

    转pdf后出现word没有的形状--对象选择窗格(同时选择多个形状.图形) word转pdf后,页面边缘突然出现一根线或者其他东西,但是回到word中找,又没有看到,好奇怪!想要了解其中的原因,请往下 ...

  6. exlsx中定义名称步骤_excel定义名称详解

    第一,excel定义名称的命名规则 1.名称可以是任意字符与数字组合在一起,但不能以数字开头,不能以数字作为名称,名称不能与单元格地址相同. 如果要以数字开头,可在前面加上下划线,如_1blwbbs. ...

  7. 创建输入控件(input控件、文本框、密码框、单项选择、多项选择、重置与提交按钮的设置)

    创建输入控件 input控件的相关概念 input控件的属性 input控件的类型 文本框的设置 密码框的设置 单项选择的设置 多项选择的设置 重置与提交按钮的设置 综合运用 相关概念选择题及参考答案 ...

  8. # 如何在Git上更改本地分支名称和远程分支名称

    有时候我们需要修改git分支名称,例如不合理的分支名称.本篇文章分享了如何轻松地修改Git本地分支名称和修改远程分支名称. 在Git中,通常使用分支来使开发与您的主要工作流程分开.在软件工程团队中,通 ...

  9. vue : 无法将“vue”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确, 然后再试一次 必解决技巧

    vue : 无法将"vue"项识别为 cmdlet.函数.脚本文件或可运行程序的名称.请检查名称的拼写,如果包括路径,请确保路径正确, 然后再试一次 #vue : 无法将" ...

最新文章

  1. 专升本c语言程序设计网课_2020年宜春学院专升本招生信息
  2. 根据id去重_Person Re-ID研究综述
  3. Hibernate 双向一对一实现(基于annotation)
  4. webpack笔记(2)打包src下的html文件
  5. mac地址扫描源码_iNet Network Scanner扫描网络,及时反馈WiFi信号强度!
  6. MySQL复习资料(二)——MySQL-DDL语句
  7. EventBus设计与实现分析——事件的发布
  8. windows 批处理 for循环语句
  9. 重庆大学微型计算机基础实验,计控课程方案设计书.doc
  10. 使用Jenkins自动部署博客
  11. 使用firefox44版本,弃用chrome
  12. 方舟综合指令代码大全系统综合
  13. Linux vi命令修改文件内容笔记
  14. 如何使用Axure制作产品需求文档prd
  15. 18:(基于对抗的学习)Learning a Self-Expressive Network for Subspace Clustering
  16. nuxt+tsx项目 class报错
  17. php java扩展模块_php扩展模块装安装
  18. vue实现店铺装修h5用户端实现
  19. Kubernetes API Aggregation在 Master 的 API Server 中启用 API 聚合功能注册自定义 APIService 资源实现和部署自定义的 API Serv
  20. VBA快速入门学习笔记

热门文章

  1. 使用gdb进行调试入门篇
  2. 修改web.conf不重启服务的方法
  3. [转载] python里字典的用法_python中字典(Dictionary)用法实例详解
  4. [转载] 字符串最长重复子串python_查找字符串中重复字符的最长子字符串
  5. ALTERA 命名规则
  6. 关于verilog的一些基础知识整理
  7. 最近纠结致死的一个java报错java.net.SocketException: Connection reset 终于得到解决
  8. Dijkstra求最短路径例题
  9. python数据分析之matplotlib绘图
  10. 前段之BOM ----DOM