I have a doubt on using jQuery variables. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I have a doubt on using jQuery variables.

let divE = $('div'); In jQuery, we know that the variable div, will have a DOM element in it! But what is the correct way of accessing the variable later in code? 1. $(divE); 2. $divE; 3. $.divE;

14th May 2019, 7:05 AM
Çůřîöş ßąšäñț 🇮🇳
Çůřîöş ßąšäñț 🇮🇳 - avatar
3 Answers
+ 1
Just divE. Exactly as you declared it with the let statement.
14th May 2019, 8:12 AM
Adam
Adam - avatar
+ 1
So if I want to get the text of div element, should I have to write divE.text()?
14th May 2019, 8:31 AM
Çůřîöş ßąšäñț 🇮🇳
Çůřîöş ßąšäñț 🇮🇳 - avatar
0
Yup.
14th May 2019, 11:43 PM
Adam
Adam - avatar