如何从textarea中提取DOM对象? [英] How do I extract DOM object from within textarea?
本文介绍了如何从textarea中提取DOM对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从一个已定义的textarea中提取出一个DOM对象。
示例:
< textarea id =myTextArea>< span id =sp1>一些文字< / span>< / textarea>
注意:< span>里面< textarea>被解码。我只是想找到一个特定的< span>通过它的ID在textarea中,并实例化一个新的对象。
到目前为止,我试图跟着没有用:
var spanObject = $(#myTextArea)。val()。find(span#sp1);
谢谢。
$ b $你可以这样做:$($($($ #myTextArea)。val());
I want to extract out an DOM object out of one of textarea which is defined. Example :
<textarea id="myTextArea"><span id="sp1">some text</span></textarea>
Note : <span> inside <textarea> is decoded. I simply want to find a particular <span> by its id inside the textarea and instantiate an new object out of it.
As of yet, I'm trying following to no avail :
var spanObject = $("#myTextArea").val().find("span#sp1);
Any help will be greatly appreciated !
Thanks.
解决方案You can do:
$($("#myTextArea").val());
这篇关于如何从textarea中提取DOM对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文