小编Mic*_*l B的帖子

添加到字典中的字典

我不是一个特别自信的程序员,但我到了那里.

我的问题是我有一个

    static Dictionary<string, Dictionary<string, List<string>>> testDictionary = ...
Run Code Online (Sandbox Code Playgroud)

如果Dictionary不包含当前键(字符串),我可以轻松添加键和另一个已填充的字典,如此...

   testDictionary.Add(userAgentResult, allowDisallowDictionary);
Run Code Online (Sandbox Code Playgroud)

这工作正常,当我尝试添加内部字典时,如果userAgentResult Key已经存在,我的问题就来了.

我希望这样做......

    testDictionary[userAgentResult].Add(allowDisallowDictionary);
Run Code Online (Sandbox Code Playgroud)

但.Add方法需要两个参数,即字符串键和列表值.所以我继续写这段代码......

    //this list as the dictionary requires a list
    List<string> testDictionaryList = new List<string>();
    //this method returns a string
    testDictionaryList.Add(regexForm(allowResult, url));
    //this will add the key and value to the inner dictionary, the value, and then     
    //add this value at the userAgentKey
    testDictionary[userAgentResult].Add(allowDisallowKey, testDictionaryList);
Run Code Online (Sandbox Code Playgroud)

这也有效,我的问题是这个字典被添加了很多次,而当内部字典已经包含了试图添加的密钥时,它显然是错误的.所以当

.net c# dictionary

6
推荐指数
2
解决办法
4万
查看次数

想要使用 jQuery .nextUntill 但排除中间的 div

我是 jQuery 的新手,所以请原谅我!

我有一个 PHP 函数,可以从 MySQL 数据库中返回一个博客;它返回标题、副标题和内容。

$result = getData();  
            while($row = mysqli_fetch_array($result))
            {
                extract($row);
                ?>
                    <div class="headline"><?php echo $headline ?></div>
                    <div class="subtitle"><?php echo $subTitle ?></div>
                    <div class="content"><?php echo $content ?></div>
                    <?php
            } 
Run Code Online (Sandbox Code Playgroud)

到目前为止显示了三个条目。我有一个 jQuery 隐藏内容并在使用内容上的 nextUntill 方法和 .slideToggle 单击标题时展开它。

    $(".content").hide();

$(".headline").click(function(){
    $(this).nextUntil(".headline").slideToggle(500);  
}); 
Run Code Online (Sandbox Code Playgroud)

我的问题是在每个 div 上执行 slideToggle,直到下一个标题,其中包括副标题。因此,当点击标题时,内容会显示,但标题会消失。

我不能只选择要滑动的内容,因为它会滑动所有三个内容 div 然后显示。

有没有办法排除标题和内容之间的副标题?

提前致谢!

javascript css jquery

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

标签 统计

.net ×1

c# ×1

css ×1

dictionary ×1

javascript ×1

jquery ×1