Jquery

How can I get textarea element? I can"t use document.getElementById("textid") for it

I"m doing it lượt thích this now:

var note = document.getElementById("note");var notetext = note.querySelector("#textid");but it doesn"t work in IE(8)

How else I can vày it? jQuery is ok

Thanks


*

If jQuery is okay, you can use find(). It"s basically equivalent lớn the way you are doing it right now.

Bạn đang xem: Jquery

$("#note").find("#textid");You can also use jQuery selectors lớn basically achieve the same thing:

$("#note #textid");Using these methods to lớn get something that already has an ID is kind of strange, but I"m supplying these assuming it"s not really how you plan on using it.

On a side note, you should know ID"s should be quality in your webpage. If you plan on having multiple elements with the same "ID" consider using a specific class name.

Update 2020.03.10

It"s a breeze khổng lồ use native sầu JS for this:

document.querySelector("#note #textid");If you want khổng lồ first find #note then #textid you have sầu khổng lồ kiểm tra the first querySelector result. If it fails to lớn match, chaining is no longer possible :(

var parent = document.querySelector("#note");var child = parent ? parent.querySelector("#textid") : null;
Share
Improve this answer
Follow
edited Mar 10 "đôi mươi at 15:45
answered Atruyền thông quảng cáo 25 "11 at 22:35

*

KhezKhez
9,64622 gold badges2828 silver badges5151 bronze badges
Is this answer outdated?
Yes | No
Add a bình luận |
5
Here is a pure JavaScript solution (without jQuery)

var _Utils = function (){ this.findChildById = function (element, childID, isSearchInnerDescendant) // isSearchInnerDescendant Example of use:

var myDiv = document.createElement("div");myDiv.innerHTML = "

" + "" + "" + "" + "
" + "
" + "
" + "
";var divToSearch = Utils.findChildById(myDiv, "divIdToSearch", true);
Share
Improve sầu this answer
Follow
edited Jan 15 "16 at 22:07
*

marc_s
675k158158 gold badges12531253 silver badges13881388 bronze badges
answered Feb 24 "15 at 11:40
*

Gil EpshtainGil Epshtain
5,70855 gold badges4242 silver badges6767 bronze badges
Is this answer outdated?
Yes | No
2
Add a phản hồi |
1
(Dwell in atom)
Text
Share
Improve sầu this answer
Follow
answered Feb 1 "17 at 6:39
*

Ankit ParmarAnkit Parmar
55866 silver badges20trăng tròn bronze badges
Is this answer outdated?
Yes | No
Add a phản hồi |
0
Using jQuery

$("#note textarea");or just

$("#textid");
Share
Improve sầu this answer
Follow
answered Aquảng cáo 25 "11 at 22:32
ataddeiniataddeini
4,8512323 silver badges3434 bronze badges
Is this answer outdated?
Yes | No
Add a comment |
-1
$(selectedDOM).find();function looking for all dom objects inside the selected DOM.i.e.


Paragraph 1

Paragraph 2


links

Paragraph 3


here if you write;

$("#mainDiv").find("p");you will get tree p elements together. On the other side,

$("#mainDiv").children("p");Function searching in the just children DOMs of the selected DOM object. So, by this code you will get just paragraph 1 & paragraph 2. It is so beneficial khổng lồ prevent browser doing unnecessary progress.

Xem thêm: Vỏ Xe Vision


Share
Improve this answer
Follow
answered Dec trăng tròn "15 at 5:17
efiratefirat
3,08322 gold badges3535 silver badges3838 bronze badges
Is this answer outdated?
Yes | No
Add a phản hồi |

Your Answer


Thanks for contributing an answer to Stack Overflow!

Please be sure lớn answer the question. Provide details & nội dung your research!

But avoid

Asking for help, clarification, or responding lớn other answers.Making statements based on opinion; baông xã them up with references or personal experience.

To learn more, see our tips on writing great answers.

Xem thêm: sửa lỗi quạt laptop kêu to


Draft saved
Draft discarded

Sign up or log in


Sign up using Google
Sign up using Facebook
Sign up using Thư điện tử & Password
Submit

Post as a guest


Name
Email Required, but never shown


Post as a guest


Name
Thư điện tử

Required, but never shown


Post Your Answer Disthẻ

By clicking “Post Your Answer”, you agree lớn our terms of service, privacy policy and cookie policy


Not the answer you're looking for? Browse other questions tagged javascript jquery element or ask your own question.


The Overflow Blog
Featured on Meta
Related
7629
How vày JavaScript closures work?
8092
How vì chưng I kiểm tra if an element is hidden in jQuery?
6595
How bởi vì I remove a property from a JavaScript object?
4278
How bởi you get a timestamp in JavaScript?
7711
How vị I redirect khổng lồ another webpage?
5630
How vì I include a JavaScript tệp tin in another JavaScript file?
7855
What does “use strict” vày in JavaScript, and what is the reasoning behind it?
7419
How to kiểm tra whether a string contains a substring in JavaScript?
9447
How can I remove sầu a specific nhà cửa from an array?
5960
How to return the response from an asynchronous call?
Hot Network Questions more hot questions

Question feed
Subscribe to lớn RSS
Question feed To subscribe lớn this RSS feed, copy và paste this URL into your RSS reader.


lang-js
Stack Overflow
Products
Company
Staông chồng Exchange Network
site thiết kế / logo sản phẩm © 2021 Staông chồng Exchange Inc; user contributions licensed under cc by-sa. rev2021.5.28.39383


Staông xã Overflow works best with JavaScript enabled
*

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device và discthua information in accordance with our Cookie Policy.


Chuyên mục: