I want to extract part of html string which format is given as below. This html string is returned by var contents = $("#content").html()
blah1 blah1
<p> blah2 blah2 </p>
Then I use
start = contents.indexOf("<p>");
end = contents.indexOf("</p>");
to get the start and end positions. So I can use contents.slice(start, end) to extract the string I want.
But in IE browser the <p> tag is capital <P> and in Chrome and Firefox, they user <p>
How can I include both cases so that my JavaScript function can work in all browsers? Thanks
$('#content p').text()will retrieve everything inside the P for you.