i have a string like
var str='<input type="text" name="se_tbox" value="Beauty is Fake" />';
I want to get only the value of that input box which is stored in str as Beauty is Fake
is there anyway to get it?
i have a string like
var str='<input type="text" name="se_tbox" value="Beauty is Fake" />';
I want to get only the value of that input box which is stored in str as Beauty is Fake
is there anyway to get it?
var str='<input type="text" name="se_tbox" value="Beauty is Fake" />';
alert($(str).attr('value'));
// or
alert($(str).val());
You can create the element and access the attribute after that:
var myInput = document.createElement(str);
alert(myInput.value);
You can use jquery
$('<input type="text" name="se_tbox" value="Beauty is Fake" />').val()
or regular expression
'<input type="text" name="se_tbox" value="Beauty is Fake" />'.match(/value="([^"]*)"/)[1]
You shouldn't stringify your HTML to process it.
But if you have to, you can use a regexp to get the value:
var val = '<input value="Beauty is Fake" />'.match(/value="([^\"]+)/)[1];