jQuery对象到JavaScript对象 [英] jQuery object to JavaScript object

查看:53
本文介绍了jQuery对象到JavaScript对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个像var txtarea = $('textarea')这样的textarea,如何使用JavaScript属性value而不是jQuery属性val()为其设置值?

If I have a textarea like var txtarea = $('textarea'), how can I set the value to it using the JavaScript property value, and not the jQuery property val()?

我认为我需要将txtarea转换为JavaScript对象,但是我该怎么办?

I think I need to convert txtarea to a JavaScript object, 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对象到JavaScript对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆