Assigning A CSSClass To Each Li Element In An Unordered List Programmatically
I've an unorderedlist something like this.
- root
- Tree Node 1&l
Solution 1:
JavaScript:
You could use the DOMObject.innerHTML read/write property. Or, jQuery's .append().
For the attributes, the DOMObject.setAttribute() should get you all the way.
Check out this piece of jQuery documentation and this.
Am I missing some functionality you wanted?
Solution 2:
you are doing the wrong thing.
instead of that approach, i would suggest a different one
- Generate the ul element with an id or class
- use that id or class in your style sheet
for e.g
<ul>
<li>
<span>root</span>
<li>
</ul>
i would generate like
<ul class='mylist'>
<li>
<span>root</span>
<li>
</ul>
my css would contain
ul.mylist {
write your style properties
}
ul.mylist li{
write your style property for li element
}
Then your records will be displayed properly.
Post a Comment for "Assigning A CSSClass To Each Li Element In An Unordered List Programmatically"