I need to find input value in a string, it should look something like this:
var someHtml = "some text, <div id='somediv'></div> <input type='text' value='somethin' />";
$(someHtml).find('input').val();
this ofcourse doesn’t work so how can i do that?
First you need to escape the double quotes or use single quotes in
someHtmlstring which I don’t think so is the same in actual case but still. And instead of usingfindyou have to usesiblingsbecauseinputis thesiblinginside$(someHtml)or wrap the wholehtmlinside adivand then can usefindmethod.Try this.
Alternatively you can use this too.
Demo