I am currently working on a Rate my professor Chrome extension that displays professor ratings on the workday. However, I am having some problems for access the specific span element by using getElementsByClassName.
The issue with your code is that getElementsByClassName returns a collection of elements, not a single element. Therefore, you need to access a specific element from this collection using an index, like courses[0], or loop through the collection. Additionally, textContent should be accessed from an individual element within the collection, not directly from the collection itself. Here’s how you can fix it:
javascript
Copy code
let courses = document.getElementsByClassName('gwt-InlineLabel WG5F WF4F');
for(let i = 0; i < courses.length; i++) {
console.log(courses[i].textContent);
}
This will log the textContent of each element that matches the specified class names.