2016-04-29 11 views
0

jsは分かりませんが、時にはそれを使用する必要がありますので、ごめんなさい、質問は簡単ですが、私は別のものを試してみて、私にとってはうまくいきません。ツリートグルをロード時に閉じます

私はツリーを持っていて、クリックしたときにツリーブランチを実際に表示して隠すスクリプトがあります。

ただし、デフォルトでツリーは開いています。最初に読み込まれたときにツリーを強制的に閉じることができますか?

 <!-- 

- HIDE DISPLAY TREE BRANCH WHEN CLICKED ON HEAD ITEM --> 
      <script> 
        $(document).ready(fu 

nction() { 
        $('label.tree-toggler').click(function() { 
       $(this).parent().children('ul.tree').toggle(300); 
        }); 
        }); 
     </script> 

これは私のソースのhtml

     <ul class="nav nav-list tree"> 




             <li><div>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 
              S: # 2 Men Fashion (<i> <a href="/item/subcategory/subcategory_details/2"> Details </a> - <a href="/item/itemgroup/new/2/http://127.0.0.1:8000/item/category/list/%3Fid=2&name=&keywords=&author=&creation_time=/">Add Itemgroup</a> - 
              <a href="/item/subcategory/edit/2/http://127.0.0.1:8000/item/category/list/%3Fid=2&name=&keywords=&author=&creation_time=/">Edit</a> - 
              <a href="/item/subcategory/delete/2/http://127.0.0.1:8000/item/category/list/%3Fid=2&name=&keywords=&author=&creation_time=/">Delete</a></i>)</div> 
               <ul class="nav nav-list tree"> 




                  <li><div><i>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 
                   I: # 21 ffdsfdsf </i>(<i><a href="/item/itemgroup/itemgroup_details/21">Details </a>- 
                   <a href="/item/itemgroup/edit/21/http://127.0.0.1:8000/item/category/list/%3Fid=2&name=&keywords=&author=&creation_time=/">Edit</a> - 
                   <a href="/item/itemgroup/delete/21/http://127.0.0.1:8000/item/category/list/%3Fid=2&name=&keywords=&author=&creation_time=/">Delete</a></i>)</div> 



                  </li> 




                  <li><div><i>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 
                   I: # 22 saddascsa </i>(<i><a href="/item/itemgroup/itemgroup_details/22">Details </a>- 
                   <a href="/item/itemgroup/edit/22/http://127.0.0.1:8000/item/category/list/%3Fid=2&name=&keywords=&author=&creation_time=/">Edit</a> - 
                   <a href="/item/itemgroup/delete/22/http://127.0.0.1:8000/item/category/list/%3Fid=2&name=&keywords=&author=&creation_time=/">Delete</a></i>)</div> 



                  </li> 




                </ul> 



           </li> 

答えて

1

をあなたが使用CSSは<ul class="nav nav-list tree" style="display:none">

やjqueryのを呼び出すようなあなたのUL

display:noneを追加しますか、ページがロードされました$(this).parent().children('ul.tree').css('display', 'none');

1

使用<ul class="nav nav-list tree" style="display:none;">です。ワット・jqueryのトグル、(目に見える。)なし(隠された)またはブロックのいずれかに表示を設定されているん

関連する問題