I am using jsTree to build my tree within Oracle APEX v4.2, which all works fine.
What I am after and unsure how to do is, whenever a node in the tree starts with the letter 'S', within the whole tree, I would like to highlight these nodes only with a background colour of say yellow.
Example of result that I after is seen below where the nodes that I want to have a background colour have been marked with a <*>
KING
----------JONES
--------------------SCOTT <*>
--------------------FORD
------------------------------SMITH <*>
----------BLAKE
--------------------ALLEN
--------------------WARD
--------------------MARTIN
--------------------TURNER
--------------------JAMES
----------SAM <*>
An example of the jsTree, not so much of the example I have above can be found here from another thread that Tom assisted me with, here in SO, i.e. jsTree and Oracle APEX - see here:
Username: apex_demo
Password: demo
http://apex.oracle.com/pls/apex/f?p=69001:2
Based on this example, which is using the same concepts (jsTree), I would expect that only Shelly Noble would be highlighted but if there were other names that started with "S", these would also be highlighted with a background colour of yellow.
Given the HTML structure of the jsTree example in your question, the following should work:
$('#treecontainer a').filter(function() {
return /^S/i.test($.trim($(this).text()));
}).addClass('highlight'); //amend the class as needed
Example fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With