jQuery Selectors


#1


https://www.codecademy.com/courses/learn-javascript/lessons/javascript-dom/exercises/jquery-selectors?action=lesson_resume&link_content_target=interstitial_lesson


When I run the code, I get the following alert message: [object Object]

Using jQuery I have selected the class skillset. But why do the words 'object Object' appear in the alert message. Should not I be getting a message which includes the class name skillset?


function main(){
  var $skillset=$('.skillset');
  alert($skillset);
  
}
$(document).ready(main);


#2

When you use alert() the browser will return the type. What are you trying to get?


#3

Skillset is a class, not an object. So the alert message should say 'Class'. Is this correct?


#4

Jquery is a subsidiary of Javascript which uses standard OOP rules which in this case, treats skillset as an object.


#5

Ok, Thanks for that! :slight_smile: But, why does the word Object appear twice?


#6

Just as a means of reference.


#7

This topic was automatically closed after 7 days. New replies are no longer allowed.