How to extract html element into a variable after data is successfully returned from an ajax response?
This is the ajax call containing the following returned data
$.getJSON("test.php",function(data)
{
$.each(data, function(key, value)
{
alert(value); // this is working but don't know how to extract the strong element from the p element into a variable
});
});
I get the following html data returned from an ajax response
<p id="testResults"><strong id="testNumber">Test 1</strong> passed - date </p>
How do I get the strong html element into a variable for later usage like this....
var testNumberHtml = "<strong id='testNumber'>Test 1</strong>";
and then put the p element into another variable, like this...
var testResultsHtml = "<p id="testResults"> passed - date </p>";