1

I am trying to add the following code to Wordpress but it doesn't seem to work. The same code in a fiddle works.

Please help.

$(".box").hover(

function (e) {
$('.box').not(this).addClass('grey')

}, // over
function (e) {
$('.box').removeClass('grey')

} // out
);

1 Answer 1

1

You have to wrap it in the noConflict mode. Like:

jQuery(function($){
// Your jQuery code here, using the $
});

See: http://learn.jquery.com/using-jquery-core/avoid-conflicts-other-libraries/

So, that would boil down to

jQuery(function($){
    $(".box").hover( function (e) {
         $('.box').not(this).addClass('grey');    
    }, // over
    function (e) {
         $('.box').removeClass('grey');    
    } // out
);
});
Sign up to request clarification or add additional context in comments.

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.