If instead of .vanish we use "div"


#1

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

Just one little doubt. If I use "div" inside the paranthesis instead of .vanish, will it not work in a similar manner?


#2

What will that do to the specificity?


#3

If you use 'div', you will targets all <div> tags on the site. That is generally a bad idea.


#4

all DIVs anyways contain .vanish right? Then how is it any different?


#5

all div's contain .vanish


#6

Careful how you use that word 'all' around programmers. They might rush the open bar.

The definition of 'all' in programming is literal; it is not something to be trifled with.


#7

oh I didnt knew that. Really sorry if it was offensive. It was highly unintentional. But can you help solve my query now?


#8

It was not offensive. I was jesting.


#9

Is there present a BUTTON element and a group of elements with class, 'vanish'?


#10

In this case - maybe. In every code you will ever write? I doubt it so much that I can say 'no' for sure. Don't learn the bad practice, it's great you think of other ways to tag everything that has class 'vanish' on it. But if you want div elements that also have vanish, you can do this $('div.vanish').

Your code seems right, so I'm guessing you managed to pass the exercise? If not, what's the problem mate? Show us your html code, you already showed javascript and it's fine.


#11

I passed the excericse even before posting this question. My intention for posting this question was due to other reasons. But I understood. Thank you all for the support. :slightly_smiling: