开发者

jquery check if element exist in val

开发者 https://www.devze.com 2023-02-09 23:34 出处:网络
Why is var x giving 0 length for iframe开发者_运维知识库. I\'m trying to check if iframe tag exits inside 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> 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号