1
我一直在爲這一整天苦苦掙扎,並試圖通過這個question列出的步驟,但我不能發現問題。JQuery .find()在我的IE中不工作
我使用quicktree插件來顯示我的無序列表中的一棵樹。
如果我刪除線
<li><a href="#" title="Add a New Page" class="addnewpage-icon addnewpage" id="addnewpageid5">hello<a/>world</li>
它的工作原理但包括行也不會。
在Chrome和FF中沒問題。
<head>
<title>jQuery quickTree plugin example</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="stylesheet" type="text/css" href="http://www.prismstudio.co.uk/tutorials/quickTree/0.4/quickTree.css" />
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
jQuery.fn.quickTree = function() {
return this.each(function(){
//set variables
var $tree = $(this);
var $roots = $tree.find('li');
//set last list-item as variable (to allow different background graphic to be applied)
$tree.find('li:last-child').addClass('last');
//add class to allow styling
$tree.addClass('tree');
//hide all lists inside of main list by default
$tree.find('ul').hide();
//iterate through all list items
$roots.each(function(){
//if list-item contains a child list
if ($(this).children('ul').length > 0) {
//add expand/contract control
$(this).addClass('root').prepend('<span class="expand" />');
}
}); //end .each
//handle clicking on expand/contract control
$('span.expand').toggle(
//if it's clicked once, find all child lists and expand
function(){
$(this).toggleClass('contract').nextAll('ul').slideDown();
},
//if it's clicked again, find all child lists and contract
function(){
$(this).toggleClass('contract').nextAll('ul').slideUp();
}
);
});
};
</script>
<script type="text/javascript">
$(document).ready(function(){
$('ul.quickTree').quickTree();
});
</script>
</head>
<body>
<ul id="0" class="quickTree">
<li id="currentId4"><a href="editpage/5" class="show-always">home</a>
<ul id="4">
<li><a href="editpage/5" class="show-always">home</a> one</li>
<li><a href="editpage/5" class="show-always">home</a> two</li>
<li><a href="editpage/5" class="show-always">home</a> nmnmnm</li>
<li><a href="editpage/5">home</a> aaaaa</li>
<li><a href="editpage/4" class="show-always">hello<a/>world</li>
<li><a href="editpage/5" class="show-always">home</a> nmnmnm</li>
<li><a href="#" title="Add a New Page" class="addnewpage-icon addnewpage" id="addnewpageid5">hello<a/>world</li>
</ul>
</li>
<li id="currentId5"><a href="editpage/5" class="show-always">where</a>
<ul id="4">
<li><a href="editpage/5" class="show-always">home</a> one</li>
<li><a href="editpage/5" class="show-always">home</a> two</li>
<li><a href="editpage/5" class="show-always">home</a> hghghgh</li>
</ul>
</li>
<li><a>nmnmnmnm <a/></li>
哈哈,我一直盯着這麼久,我看不到樹木,不見森林!由於新功能的原因,無法接受您的回答。謝謝! – 2010-09-14 14:50:15
@Nicholas有什麼新功能? – jrharshath 2010-09-14 14:55:05
@這裏是狼 - 彈出一個對話框,記下時間,直到你接受答案爲止。我第一次看到它。 – 2010-09-14 14:58:23