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?
Use document. getElementById(id_name) to Get Input Value in JavaScript. We give the id property to our Dom input element, and then use document. getElementById(id_name) to select DOM input element, you can simply use the value property.
$(str).val(); // this would do it...
have a look
var str='<input type="text" name="se_tbox" value="Beauty is Fake" />';
alert($(str).attr('value'));
// or
alert($(str).val());
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]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With