The structure of the dynatree is like this:
<ul class="dynatree-container">
<li class="">
<span class="dynatree-node dynatree-has-children dynatree-exp-c dynatree-ico-c">
<a class="dynatree-title" href="#">Alimentary</a>
</span>
</li>
<li class="">
<span class="dynatree-node dynatree-expanded dynatree-has-children dynatree-exp-e dynatree-ico-e">
<a class="dynatree-title" href="#">Fruits</a>
</span>
<ul style="">
<li class="">
<span class="dynatree-node dynatree-exp-c dynatree-ico-c">
<a class="dynatree-title" href="#">Banans</a>
</span>
</li>
</ul>
</li>
<li class="">
<span class="dynatree-node dynatree-has-children dynatree-exp-c dynatree-ico-c">>
<a class="dynatree-title" href="#">Cosmetics</a>
</span>
</li>
</ul>
I want to search through the data and if "pineapple" exists in the tree ,show it in bold. In javascript i wrote a method onkeyPressed:
function Search(value)
{
for(var i=0;i<document.getElementsByTagName('li').length;i++)
{
var node=document.getElementsByTagName('dynatree-title')
if (node.data.href ==value) {
//expand the tree
}
}
}
I am not sure how can i visit all the nodes search for the value. Does anyone has an idea?
You can use Jquery to search the node:
function Search(value){
$(".dynatree-title").each(function(){
if($(this).text() == value){
$(this).html("<strong>"+$(this).text() +"</strong>");
}
});
}