使用jquery单击按钮时如何获取页面中元素的类名 [英] how to get class names of elements in a page when click on a button using jquery

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

问题描述

在我的页面中,我有不同的标签和标签的不同类现在我需要使用jquery获取所有元素的类名....是否可能?

In my page i have different tags and different classes for tags now i need to get class names of all the elements using jquery ....is it possible?

推荐答案

试试这个:

Try this:


' < span class =code-string>#div1')。attr(' class'); // 输出:div1cls
('#div1').attr('class');//output : div1cls


' #div2')。attr(' < span class =code-string> class'); // output:div2cls
('#div2').attr('class');//output : div2cls



问候..


Regards..


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

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