1
Has a top #header
that adds the class .hide-bar
when scroll but when returning to the top, this class.
How to check with jQuery if you are class
is present in this id
or not? I need this check to disappear/return with certain blocks.
1
Has a top #header
that adds the class .hide-bar
when scroll but when returning to the top, this class.
How to check with jQuery if you are class
is present in this id
or not? I need this check to disappear/return with certain blocks.
5
You can use the method .hasClass()
jQuery:
if($('#header').hasClass('hide-bar')){
// fazer algo caso tenha a classe
}
I usually avoid jQuery whenever possible in simple features like this. To do this with native Javascript can do so:
var elemento = document.getElementById('header');
if(elemento.className.indexOf('hide-bar') != -1){
// fazer algo caso tenha a classe
}
Or using Javascript in modern browsers (IE9+):
var elemento = document.getElementById('header');
if(elemento.classList.contains('hide-bar')1){
// fazer algo caso tenha a classe
}
Browser other questions tagged jquery html css
You are not signed in. Login or sign up in order to post.