如何将jQuery对象转换为Element? [英] How can I convert a jQuery object to an Element?
本文介绍了如何将jQuery对象转换为Element?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个像var textarea = $('textarea')
这样的textarea
,如何使用JavaScript属性value
而不是jQuery属性val()
为其设置值?
If I have a textarea
like var textarea = $('textarea')
, how can I set the value to it using the JavaScript property value
, and not the jQuery property val()
?
我认为我需要先将textarea
转换为JavaScript对象,但是我该怎么办?
I think I need to convert textarea
to a JavaScript object first, but how do I?
推荐答案
您可以使用解引用运算符,也可以使用 .get()
检索与jQuery对象匹配的DOM元素的a>方法."
You can use the dereferencing operator, or the .get()
method to "Retrieve the DOM elements matched by the jQuery object."
示例:
txtArea[0].value = "something";
或:
txtArea.get(0).value = "something";
这篇关于如何将jQuery对象转换为Element?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文