Lots of Errors in JavaScript and the DOM


#1

Does anyone have code for this that works. I found mine worked (sometimes), would tick the exercise as OK but often didnt do what it should.
Also when I try to RESET - it doesnt reset. It removes the code but keeps the green ticks to the exercises.

.


#2

Exercise and code plz :smiley:


#3

Pretty much all of it! Learn JavaScript 8 JS & the DOM


#4

EG: 5.jQuery Selectors:

function main() {
$('.skillset').hide();
$('.skillset').fadeIn(1000);

$('.projects').hide();

$('.projects-button').on('click', function() {
$(this).next().slideToggle(400);
$(this).toggleClass('active');
$(this).text('Projects Viewed');
});
}

$(document).ready(main);

ERRORS:
expected [Function
expected [Function

And it is not possible to RESET (restart this exercise)

:slight_smile:


#5

U should just Change the order of the Selector's that use $(this) like this:

function main(){ 
$('.skillset').hide();
  $('.skillset').fadeIn(1000);
  $('.projects').hide();
  $('.projects-button').on('click', function(){
    $(this).toggleClass('active');  // add or remove more or one classes
    $(this).text('Projects Viewed');  // obvious
    $(this).next().slideToggle(400); //Display or hide the matched elements with a sliding motion.
  }); 
}

#6

Brilliant – thank you
:slight_smile:


#7

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