Kamalakannan Kamalakannan - 1 year ago 109
jQuery Question

Add Class on ready, remove class on hover

I'm creating my portfolio website. I'm looking to add class on document ready, and remove/change that class to a different class on hover.
I'm using lightgallery & CSS gram filters to my images on load and hover.

$(document).ready(function() {
$("#gallery li a").load(function(){
$("#gallery li a").hover(function(){
}); });

the jQuery code above didn't seem to work well.

Please help, Thanks.

Answer Source

An anchor doesn't load, it's just there from the start and has no external resource to load, so there's no onload handler

$(document).ready(function() {
    $("#gallery li a img").addClass("inkwell");

    $("#gallery li a").on({
      mouseenter : function() {
      mouseleave : function() {


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download