How does jQuery get class_html/css_WEB-ITnose based on value

WBOY
Release: 2016-06-24 11:40:52
Original
1252 people have browsed it

See clearly, the class selector is not required to obtain the value!


Study hard
Tiantianshangshang
...


is a loop display, and the class of is a loop Numbered, now I know that the value of a certain is 'study hard', how can I get class ='1'


JS, Jquery will do


Reply to discussion (solution)

$.each($('tr td'),function(){     if($(this).text()=="天天向上")    {          alert($(this).attr("class"))    }})
Copy after login
Copy after login

$.each($('tr td'),function(){     if($(this).text()=="天天向上")    {          alert($(this).attr("class"))    }})
Copy after login
Copy after login








Thank you, Daniel, I just went to the meeting.

<table>	<tr>		<td class="2">天天向上</td>		<td class="1">好好学习</td>	</tr></table><script type="text/javascript" src="http://code.jquery.com/jquery-1.11.2.min.js"></script> <script type="text/javascript">alert($("td:contains('好好学习')").attr("class"));</script>
Copy after login
Copy after login

<table>	<tr>		<td class="2">天天向上</td>		<td class="1">好好学习</td>	</tr></table><script type="text/javascript" src="http://code.jquery.com/jquery-1.11.2.min.js"></script> <script type="text/javascript">alert($("td:contains('好好学习')").attr("class"));</script>
Copy after login
Copy after login





No points...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!