var inputs = document.getElementsByTagName("li");
for(var i = 0; i < inputs.length; i++)
{
if(inputs[i].id.indexOf(startsWith) == 0) {
eles.push(inputs[i].id);
}
}
for(var j=0; j < eles.length; j++) {
document.getElementById(eles[j]).setAttribute("class","jstree-checked");
}
Am taking out the ids that starts with certain pattern in the li
tags of my document.
I am changing the class of the li
tags of the resulting ids.
I also need to disable the contents present in the li
tag as a whole.
Is it possible to do this using javascript or jquery?
UPDATE:
I've a checkbox and text message inside each <li>
tag.
Need to disable the checkbox(non clickable) and display the text as disabled.
<li id="1_1" class="jstree-leaf jstree-no-icons jstree-last jstree-leaf jstree-unchecked" crawllocation="D:\company\deploy\AppServer\fusionEAR.ear" name="fusionEAR.ear">
<ins class="jstree-icon"> </ins>
<a class="" href="#" style="">
<ins class="jstree-checkbox"> </ins>
<ins class="jstree-icon "> </ins>
fusionEAR.ear
</a>
</li>
Tried these:
for(var j=0; j < eles.length; j++){
//jQV6('#jstreeDivforBrowse').jstree("check_node","#"+eles[j]);
document.getElementById(eles[j]).setAttribute("class","jstree-default jstree-checked");
//$.jstree._reference('#jstreeDivforBrowse').set_type("disabled", "#"+eles[j]); -- First try to disable
//eles[j].disabled = true;-- Second try to disable
//$("#"+eles[j]).attr('disabled', 'true');-- Third try to disable
//$("#"+eles[j]).addClass("jstree-leaf jstree-no-icons jstree-last jstree-leaf jstree-checked").find(":input").attr("disabled", "disabled");-- Fourth try to disable
}
In any of these tries I couldnt find my checkbox disabled. But the task of selecting the check box is successful for required ids by changing the class name inside the loop as given.