I have the references below in my form
<link type="text/css" rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
I am trying find the contents of the title element from the below string.
var mytext = "<head><title>bad error</title></head>";
var err = mytext.find('title');
I am getting Object doesn't support property or method 'find' error.
My requirement is I want to get text between an element <title>.
find is jquery method, not string method. Wrap your HTML string in jquery.
Use text to get the innerText of an element.
$(mytext).find('title').text();
Example:
var mytext = "<head><title>bad error</title></head>";
var err = $(mytext).find('title').text();
alert(err);
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