Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Fernando Jimenez
Courses Plus Student 8,455 PointsIssues selecting element Jquery. for some reason I can't get to select this element.
so here is the page https://www.utahadvocates.com/ppc-car-accident-lawyer-free-consultation
within the DOM, there is an element called
<span class="responsive-text lmc_dbd lmc_track">801-326-0809</span>
I am trying to change the phone number so i am first trying to select the element, then change it by using text with the new number.. but when i try
var x = jQuery("responsive-text lmc_dbd lmc_track);
console.log(x); // it just says undefined.
2 Answers
KRIS NIKOLAISEN
54,974 PointsI was able to select the element and change the text as follows:
var x = $('.responsive-text.lmc_dbd')[0];
console.log(x);
x.innerText = "123";
Here is a workspace with test page https://w.trhou.se/smo9xk7a9p
Adam N
70,280 PointsTry
var x = $('.responsive-text.lmc_dbd');
That says to select any element that uses both of those classes. Should only select that one element.
Let me know if this helps here
Fernando Jimenez
Courses Plus Student 8,455 PointsNope it didn't work, I am not sure why. When I console log it says "undefined" still
Fernando Jimenez
Courses Plus Student 8,455 PointsFernando Jimenez
Courses Plus Student 8,455 PointsAwesome, it worked... so I guess it gets stored as an array.