6. Selecting By Class not able to correlate with Jquery doc


#1


https://www.codecademy.com/courses/web-beginner-en-GfjC6/1/2?curriculum_id=50a3fad8c7a770b5fd0007a1#

Not stuck, but would like to have further understanding on the 'working' which to my looks it should be incorrect and the 'non-working' which should be correct, based on the fact that I correlated with jquery docs.

INITIAL CODE>

$(document).ready(function() {
$().click(function() {
});
});

WORKING CODE (as per submit button)>

$(document).ready(function() {
$('button').click(function(
$('.vanish').fadeOut('slow'):wink: {
});
});

**This code by the way gives some " ; " syntax issue but still allows to continue.

NON WORKING CODE (as per submit button)>

$(document).ready(function() {
$('button').click(function() {
$('.vanish').fadeOut('slow');
});
});

As per the jquery api documentation, I see that the examples given include the code inside {} and not inside the () of the click.

Taken from: http://api.jquery.com/click/

$( "#target" ).click(function() {
alert( "Handler for .click() called." );
});

So as you can see it's .click(function() {-yourcodehere-} )

I'm not sure where my mistake is, or probably have misunderstood something. Any insights or other doc to point me in the right direction are welcome.


EDIT:
This is the fiddle that I did: https://jsfiddle.net/g5g6r9gL/


#2

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