<html>
<head>
<title></title>
<script type="text/javascript">
window.onload = function () {
var oDiv = document.getElementById("div1")
var aLi = oDiv.getElementsByTagName("li")
var sHtml = ""
for (var i = 0, l = aLi.lengthi <li++) {
sHtml += aLi[i].innerHTML
}
oDiv.innerHTML = sHtml
}
</script>
</head>
<body>
<div id="div1">
<ul>
<li><a href="#">删除父级LI</a></li>
<li><a href="#">删除父级LI</a></li>
<li><a href="#">删除父级LI</a></li>
<li><a href="#">删除父级LI</a></li>
<li><a href="#">删除父级LI</a></li>
<li><a href="#">删除父级LI</a></li>
<li><a href="#">删除父级LI</a></li>
<li><a href="#">删除父级LI</a></li>
<li><a href="#">删除父级LI</a></li>
</ul>
</div>
</body>
</html>
1、正则表达式去掉html标签代码如下:/// <Header>/// 去除 HTML tag
/// </Header>
/// <param name="HTML">源</param>
/// <returns>结果</returns> public static string StripHTML(string HTML) //google "StripHTML" 得到{ string[] Regexs =
{
@"<script[^>]*?>.*?</script>",
@"<(\/\s*)?!?((\w+:)?\w+)(\w+(\s*=?\s*(([""'])(\\[""'tbnr]|[^\7])*?\7|\w+)|.{0})|\s)*?(\/\s*)?>",
@"([\r\n])[\s]+",
@"&(quot|#34)",
@"&(amp|#38)",
@"&(lt|#60)",
@"&(gt|#62)",
@"&(nbsp|#160)",
@"&(iexcl|#161)",
@"&(cent|#162)",
@"&(pound|#163)",
@"&(copy|#169)",
@"(\d+)",
@"-->",
@"<!--.*\n"
}
string[] Replaces =
{
"",
"",
"",
"\"",
"&",
"<",
">",
" ",
"\xa1", //chr(161),"\xa2", //chr(162),"\xa3", //chr(163),"\xa9", //chr(169),"",
"\r\n",
""
}
string s = HTML
for (int i = 0i <Regexs.Lengthi++)
{
s = new Regex(Regexs[i], RegexOptions.Multiline | RegexOptions.IgnoreCase).Replace(s, Replaces[i])
}
s.Replace("<", "")
s.Replace(">", "")
s.Replace("\r\n", "")
return s
}
}
2、可以直接复制到txt,然后保存成为.html,在浏览器中设置即可!
用Js匹配li的t内容就可以的,看如下代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html charset=utf-8" />
</head>
<script type="text/javascript" src="jquery.js"></script>
<body>
<div id="seltime1">
<ul id="tbustime">
<li t="11:00" p="60" c="50">
<div>11:00-12:00</div>
<div><b>50/50</b></div>
</li>
<li t="13:00" p="30" c="10">
<div>13:00-13:30</div>
<div><b>10/10</b></div>
</li>
<li t="13:30" p="60" c="10">
<div>13:30-14:30</div>
<div><b>10/10</b></div>
</li>
</ul>
</div>
<div>
<input type="button" value="移除" id="removeLi">
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
$('#removeLi').click(function(){
$('#tbustime').find('li').each(function(){
var t = $(this).attr('t')
if(t == '13:30'){
$(this).remove()
}
})
})
})
</script>
</html>
粘贴后试试,记得引入jquery类库,若有任何疑问,欢迎追问....
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)