Get div value from string
3 answers
You need to convert the text to a jQuery object and then use the standard move methods
str ='<div id="example">Text</div><div id="test">Test</div>'; var live_str = $('<div>',{html:str}); var example = live_str.find('#example').text(); // example variable now holds 'Text' var test = live_str.find('#test').text(); // example variable now holds 'Test' demo at http://jsfiddle.net/gaby/FJSm6/
As you can see, I am setting the line as the html of another element, because otherwise the divs will be at the top level and you cannot cross them with .find() ..
+7