如何使用具有元素类型和ID的jquery选择器 [英] How to use jquery selector having element type and ID

查看:101
本文介绍了如何使用具有元素类型和ID的jquery选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此选择器 $("textarea #myTextArea").val(text);,它不起作用.如果删除ID并使用该类,它将起作用.为什么jquery无法在这里找到元素?

I'm using this selector $("textarea #myTextArea").val(text); and it's not working. If I remove the ID and use the class it's working. Why isn't jquery able to find the element here?

推荐答案

由于空格.空格表示textarea中的#myTextArea.

Because of the space. With the space it says the #myTextArea within a textarea.

$("textarea#myTextArea").val(text);

这篇关于如何使用具有元素类型和ID的jquery选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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