Jquery: How can I Get/Set html of a String Variable by using Jquery Selectors ?
Posted
by ryan.dingy
on Stack Overflow
See other posts from Stack Overflow
or by ryan.dingy
Published on 2010-03-16T08:54:06Z
Indexed on
2010/03/16
8:56 UTC
Read the original article
Hit count: 228
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
© Stack Overflow or respective owner