Answer the question
In order to leave comments, you need to log in
How to change from click to hover?
Here I have the code buttons and blocks are arrays containing the IDs of the elements I need.
$(buttons).each(function(index, id) {
$(id).click(function() {
if ($(blocks[index]).css('opacity') == 1 ) {
$(blocks[index]).css('opacity', '0');
} else {
$(bb).css('opacity', '0');
$(blocks[index]).css('opacity', '1');
};
});
});
$(buttons).each(function(index, id) {
$(id).hover(function() {
if ($(blocks[index]).css('opacity') == 0 ) {
$(bb).css('opacity', '0');
$(blocks[index]).css('opacity', '1');
} else {
$(bb).css('opacity', '0');
$(blocks[index]).css('opacity', '0');
};
})
});
Answer the question
In order to leave comments, you need to log in
$( id).click( function() {
$( this)
.off( 'click')
.on( 'hover', callback);
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question