简单的Javascript在Safari中不起作用?

时间:2015-02-05 16:42:57

标签: javascript

这个脚本在chrome和firefox中工作得很好但不是safari ...

请帮忙吗?

<ul class="SubMenu">
    <li>Shop By Category
        <ul>
          <li>
            ----Some Text----
          </li>
        </ul>
    </li>
</ul>
$(document).ready(function () {
    $("li").click(function () {
        //Toggle the child but don't include them in the hide selector using .not()
        $('li > ul').not($(this).children("ul").toggle()).hide();

    });
});

1 个答案:

答案 0 :(得分:0)

为了测试起见,我在包含以下内容的html文件中添加了所有这些内容,并且所有浏览器中的一切似乎都正常。怎么会失败?

<html>
<head>
    <script src="https://code.jquery.com/jquery-2.1.3.min.js" charset="utf-8"></script>
    <title></title>
</head>
<body>
    <ul class="SubMenu">
      <li>Shop By Category
        <ul>
          <li>
            ----Some Text----
          </li>
        </ul>
      </li>
     </ul>
 <script type="text/javascript">
    $(document).ready(function () {
      $("li").click(function () {
        //Toggle the child but don't include them in the hide selector using .not()
        $('li > ul').not($(this).children("ul").toggle()).hide();

        });
    });

 </script>

</body>
</html>