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!
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
carine todmia6,071 Points
i thought $(".selected") was considered improper syntax for jquery
Pavle Lucic10,801 Points
carine todmia hi,
Maybe you get confused by this code
The first part $(".selected") - it is Jquery selector (almost same as you would select elements in CSS). It selects html element with class selected and create jquery object from him.
Another part is .removeClass("selected") - it is Jquery method (there is not dot at the end). So every object can have methods. This method removeClass, removes class selected from $(".selected") html element.
$("") syntax is the most common way of selecting the elements in the DOM with jQuery. You can use it to select an element using HTML tag names the way you do in CSS:
You can also use it select an element by its class or id:
$(".selected").hide() // or $("#form-submit").hide().