0

Using hover class of css.

I have a label called "show" & i have a button. So basically i want to change the background of the button (want the same color of hover) when i hover on the label i.e i want to use btn:hover {} class which is already there in css.

show - > on hover -> addClass - > btn:hover {} to (btn)  

$('.addingAction').hover(function() {
        $('.btnRBlk').css({
            //use hover class

        }};                 
        },function() {

});
3
  • Include your HTML and CSS please. The question isn't entirely clear. Commented Jun 8, 2012 at 9:09
  • sorry, from your question im confused. Commented Jun 8, 2012 at 9:09
  • You can't manipulate CSS pseudo-classes via JavaScript. Commented Jun 8, 2012 at 9:11

3 Answers 3

1

You may be able to do this with pure CSS (no jQuery), but you would need to post your HTML.

However, as it is, the easiest way to do this would be to add a class name to your CSS:

btn:hover, .hovered {
    /* Styles */
}

And then use the jQuery addClass and removeClass methods:

$('.addingAction').hover(function() {
    $('.btnRBlk').addClass("hovered");
}, function() {
    $('.btnRBlk').removeClass("hovered");
});
Sign up to request clarification or add additional context in comments.

Comments

1

Try to do this :

$(".addinAction").hover(function(){
    $(".btnRBlk").trigger("mouseenter");
},function(){
    $(".btnRBlk").trigger("mouseleave");
});

Comments

0

You jquery code has error

   $('.addingAction').hover(function() {
            $('.btnRBlk').css({
                //use hover class

            });//this was errorneaous                 
            },function() {

    });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.