开发者

jquery get all parent and child elements of textarea input

consider this html code

<textarea>
    <object>
      <embed></embed>
      <div></div
    </object>
</textarea>

If i issue the following jquery command

var x = $('textarea').val();
$(x).contents().and开发者_开发知识库Self().children().get()

i get an array with list of element inside the textarea. [embed, div], but i'm not getting the object tag.

Now if i issue the same jquery command on this

<textarea>
    <iframe>
    </iframe>
</textarea>

I get an error since iframe is a parent element and i get an error.

The point is to look inside the textarea val and find if a specific tag exists. I need to be able to search all parent and child elements of val.

TypeError: a.contentWindow is null 


interesting issue. You may want to use contentEditable instead. That should solve your problem.


To get all the children you have a specific selector:

$('textarea > *')

Try if that works

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜