JavaScript and the DOM (jQuery) Flashcards

1
Q

How would you select an HTML class in a javascript file? (JS Code)

A

Need to put answer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How would you select an HTML element with jQuery?

A

$(‘.skillset’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

With the help of jQuery how can we make a cool effect where when the website is loaded with a fade in effect?

A

Use an element which surrounds all of the elements you wish to put the effect on, like so:
$(‘.projects’).hide();
$(‘.skillset’).hide();
$(‘skillset’).fadeIn(1000);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can make it, so when a button is clicked on the webpage then something happens (EX. Recent Projects is clicked, it changes colors and reveals the projects)?

A
$(‘.projects-button’).on(‘click’, function (){


$(this).toggleClass(‘active’);
$(this)


});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

If I wanted the text on an element (button) to change when clicked on, how could I add this cool effect?

A
$(‘projects-button’).on(‘click’, function() {


$(this).toggleClass(‘toggleClass’);
  $(this).text(‘Projects Viewed’);
  $(this).next().slideToggle(400).
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly