Jquery: How can I Get/Set html of a String Variable by using Jquery Selectors ?
- by ryan.dingy
Hi all. Firstly, sorry for my English (I'm from China).
By reading this article(http://stackoverflow.com/questions/2421719/how-to-apply-jquery-element-selection-to-a-string-variable), I can successfully get Elements from a String which stores HTML text. For example:
var htmlstr = "<div><ul><li>some text 1</li></ul></div><div><ul id=list><li>some text 2</li></ul></div>";
var s = $('ul#list', $(htmlstr)).html();
s will be <li>some text 2</li>. It's what I want.
But the question is, if I want to add another LI element to this string (htmlstr) how can I do?
I set s = new html string but htmlstr doesn't change.
Thanks