请参阅小提琴:http://jsfiddle.net/3mpire/yTzGA/1/
使用jQuery如何从所有LI中删除"活动"类除了从根最远(最深)的那个?
<div class="navpole">
<ul>
<li class="active"><a href="#">Lorem ipsum</a></li>
<li><a href="#">Lorem ipsum</a>
<ul>
<li class="active"><a href="#">Lorem ipsum</a></li>
<li><a href="#">Lorem ipsum</a></li>
<li><a href="#">Lorem ipsum</a>
<ul>
<li class="active"><a href="#">Lorem ipsum</a></li>
<li><a href="#">Lorem ipsum</a></li>
</ul>
</li>
<li><a href="#">Lorem ipsum</a></li>
</ul>
</li>
<li><a href="#">Lorem ipsum</a></li>
<li><a href="#">Lorem ipsum</a></li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
这是期望的结果:
<div class="navpole">
<ul>
<li><a href="#">Lorem ipsum</a></li>
<li><a href="#">Lorem ipsum</a>
<ul>
<li><a href="#">Lorem ipsum</a></li>
<li><a href="#">Lorem ipsum</a></li>
<li><a href="#">Lorem ipsum</a>
<ul>
<li class="active"><a href="#">Lorem ipsum</a></li>
<li><a href="#">Lorem ipsum</a></li>
</ul>
</li>
<li><a …
Run Code Online (Sandbox Code Playgroud) I have already seen from other answers that to escape the {
or }
char in C# string.Format()
you use {{
or }}
.
But what I need to do is format a string that looks like this:
{{tag}}
Run Code Online (Sandbox Code Playgroud)
However, when I try to escape the double curly braces like this:
string.Format("{{{0}}}", "tag");
Run Code Online (Sandbox Code Playgroud)
or this:
string.Format("{{{{{0}}}}}", "tag");
Run Code Online (Sandbox Code Playgroud)
The output is always this:
{tag}
Run Code Online (Sandbox Code Playgroud)
A different way I have found that works is:
StringBuilder output = new StringBuilder();
output.Append("{{");
output.Append("tag");
output.Append("}}"); …
Run Code Online (Sandbox Code Playgroud)