小编Cha*_*ley的帖子

jQuery从UL层次结构中删除类,除了

请参阅小提琴: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)

javascript css jquery

5
推荐指数
1
解决办法
764
查看次数

How to escape double curly bracket in string.Format()

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)

c# string escaping

2
推荐指数
1
解决办法
1523
查看次数

标签 统计

c# ×1

css ×1

escaping ×1

javascript ×1

jquery ×1

string ×1