jquery check if element exist in val
Why is var x giving 0 length for iframe开发者_运维知识库. I'm trying to check if iframe tag exits inside val.
<textarea name="embed">
<iframe src="http://.."></iframe>
</textarea>
$($('#embedModal textarea').val());
var x = $textareaval.find('iframe').length;
I'm able to get a length in the example below for embed.
<object><embed></embed></object>
textareaval.find('embed').length;
Try:
$textareaval.find('iframe').andSelf( ).length
You shouldn't put HTML tags in a TextArea. Weird/Bad things happen.
For example, these two iframes render completely different in the DOM tree:
<textarea name="embed">
<iframe src="http://www.google.com"></iframe>
</textarea>
<div name="MyDiv">
<iframe src="http://www.google.com"></iframe>
</div>
精彩评论