如何在html中搜索嵌套列表中的元素? [英] how to search the elements in the nested list in html?

查看:166
本文介绍了如何在html中搜索嵌套列表中的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例:

水果

芒果

苹果

体育

网球

cricket

解决方案

你的意思是这样的吗?



 <   html  >  
< head >
< script src = http:// code。 jquery.com/jquery-1.7.2.min.js\"> < / script >
< script >
function find(text){


' li ')。filter( function (){
return


this )。text()== text;
})。css( background-color red);
}
< / 脚本 >
< style >
< / style >
< / head >
< 正文 >
< ul >
< li >
水果
< ol >
< li > Apple < / li >
< li > Grape < / li >
< / ol >
< / li >
< li >
体育
< ol >
< < span class =code-leadattribute> li > Cricket < / li >
< < span class =code-leadattribute> li > 网球< / li >
< < span class =code-leadattribute> / ol >
< / li >
< / ul >
< ; 按钮 onclick = find('Grape'); > 找到Grape < / button >
< span class =code-keyword>< / body >
< / html >


example:
fruits
mango
apple
sports
tennis
cricket

解决方案

You mean something like this?

<html>
<head>
	<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
	<script>
	function find(text){


('li').filter(function() { return


(this).text() == text; }).css("background-color", "red"); } </script> <style> </style> </head> <body> <ul> <li> Fruits <ol> <li>Apple</li> <li>Grape</li> </ol> </li> <li> Sports <ol> <li>Cricket</li> <li>Tennis</li> </ol> </li> </ul> <button onclick="find('Grape');">find Grape</button> </body> </html>


这篇关于如何在html中搜索嵌套列表中的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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