jquery按名称选择

jQuery select by class name allows us to find a specific HTML element with the value of its class attribute.

jQuery通过类名称进行选择允许我们使用其class属性的值来查找特定HTML元素。

jQuery按类别选择 (jQuery select by class)

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

以下是使用jQuery按类名选择的常规语法:

$(".classname")

$(".classname")

ID could be any value provided in the id attributes of the HTML element. You should use period character ( .) followed by the class name specified in the html element.

ID可以是HTML元素的id属性中提供的任何值。 您应该使用句点字符( ),后跟html元素中指定的类名。

$(".myClass"): This will select all HTML elements with class name equal to “myClass”.

$(".myClass") :这将选择所有类名称等于“ myClass”HTML元素。

For example if there is a HTML element in the document like <div class="myClass"> some text </div>, $(“.myClass”) will select this div and do the intended action on it. All the manipulations will affect only the elements specified with the given class name in the selector.

例如,如果文档中有一个HTML元素,例如<div class="myClass"> some text </div> ,则$(“。myClass”)将选择该div并对其执行预期的操作。 所有操作只会影响选择器中使用给定类名指定的元素。

jQuery按类选择示例 (jQuery select by class example)

This example demonstrates the use of jQuery select by its class name and changing the CSS style of the selected element.

此示例通过其类名演示jQuery select的用法以及如何更改所选元素CSS样式。

<html>
<head>
<title>jQuery select by Class</title><style>
div, span {
width: 130px;
height: 50px;
float: left;
padding: 15px;
margin: 15px;
background-color: #EEEEEE;
}
</style><script src="//code.jquery.com/jquery-3.2.1.js"></script></head>
<body>
<div class="class1">div element className="class1"</div>
<div class="class2">div element className="class2"</div>
<span class="class3">span element className="class3"</span>
<script>
$( ".class2" ).css( "border", "5px solid green" );
</script>
</body>
</html>

You can see that <div> element with class=”class2″ is selected for manipulation and some other styles are added to it.

您会看到选择了带有class =“ class2”的<div>元素进行操作,并向其中添加了其他样式。

Below image shows the output page rendered by the browser.

下图显示了浏览器呈现的输出页面。

jQuery按类选择演示 (jQuery Select by Class Demo)

jQuery按类别选择 (jQuery select by class summary)

jQuery class selector makes it easy to apply CSS class to any number of elements in the html document. This selector is very helpful in keeping uniformity of certain elements.

jQuery类选择器使将CSS类轻松应用于html文档中任意数量的元素变得容易。 该选择器对于保持某些元素的一致性非常有帮助。

翻译自: https://www.journaldev.com/4544/jquery-select-class

jquery按名称选择

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

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

    jquery按名称选择 jQuery select by name or jQuery element selector allows us to find all HTML elements wit ...

  2. 如何使用jQuery按名称选择元素?

    本文翻译自:How can I select an element by name with jQuery? Have a table column I'm trying to expand and ...

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

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

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

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

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

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

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

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

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

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

  8. python gui选择文件_GUI中选择文件

    askopenfilename(**options) 返回打开的文件名 askopenfilenames(**options) 返回打开的多个文件名列表 askopenfile(**options) ...

  9. [你必须知道的css系列]第一回:丰富的利器2:CSS选择符之子选择符、相邻选择符...

    对了,接下来要讲的属性选择符,相邻选择符,子对象选择符可能大家稍微有点陌生了,这当然也是有原因的,因为IE6及以下的浏览器并不支持这几个选择符,而 大多数从事这方面工作的技术人员,多数时候还是主要考虑 ...

最新文章

  1. Transformer 模型详解
  2. Oracle数据库之SQL连接查询
  3. 百练4103:踩方格
  4. CRM Fiori Launchpad初次登陆后返回的service metadata信息
  5. onclick 源码_仿照React源码流程打造90行代码的Hooks
  6. 大数据项目实践:基于hadoop+spark+mongodb+mysql开发医院临床知识库系统
  7. 【bfs】Replication G(P7151)
  8. 如何组合来自多个SQL表的结果(提示:有三种方式)
  9. **Dijkstra算法**
  10. 【基础】CNN是靠什么线索学习到深度信息的?——一个经验性探索
  11. 9个JQuery和5个JavaScript经典面试题
  12. 使用多串口卡后读卡器无法初始化
  13. 汽车电子零部件电磁兼容EMC测试标准
  14. html两个部分组成部分组成,html页面由哪几部分组成
  15. android studio Emulator is outdated
  16. H5页面跳转关注微信公众号页面
  17. Markdown:如何修改插入图片的大小或比例
  18. AI「照妖镜」:不仅知道你P过图,还知道你P图前长啥样
  19. CreateCompatibleDC,CreateCompatibleBitmap,SelectObject详解
  20. web前端工程师都做什么工作

热门文章

  1. STL源码剖析学习十四:算法之set相关算法
  2. 如何用VB.Net创建一个三层的数据库应用程序
  3. [转载] python面向对象编程实例
  4. [转载] python字符串只留数字_Python工匠:数字与字符串(下)
  5. [转载] pandas DataFrame apply()函数(1)
  6. [转载] java中接口(interface)详解
  7. Quartus 与modelSim联合仿真常见错误以及系统任务$readmemb和$readmemh解释
  8. 超哥笔记 --nginx入门(6)
  9. 【洛谷3157】[CQOI2011] 动态逆序对(CDQ分治)
  10. @Scheduled(cron=) spring定时任务时间设置