Похожие чаты

Anything wrong in it ? $("p:eq(1)").removeClass("blue", function(){

alert("The paragraph is now hidden");
});
});

2 ответов

8 просмотров

what is thus?

The second parameter of removeClass must be a function that returns a class or classes to remove. Your alert() must be outside, so you can wrap all in a function, also I don't recommend targeting mutable elements like p:eq(1), it is a better practice to target element's class to prevent modification of other elements (like if you insert a new <p> at the beginning the target will change) You can wrap all in a function: $("p:eq(1)").on("click", function() { $(this).removeClass("blue"); alert("hidden?"); });

Похожие вопросы

Карта сайта