3

I am pretty new to jQuery and here is my problem with this website.

As you see, There is a some small pictures in the right. I wrote a very simple script with HOVER in order to change the opacity of the element when mouse over. But this doesn't work until I do a small change in that script in Firebug (e.g. just by press space in any line of script it becomes active). and then it works! I completely confused by this.

If anyone can help me through, I can correct the same problem with another script that change the position of those small pictures as you move over.

I am searching for any solution that can do the same thing as I want.

Thank you and goodbye presently.

1 Answer 1

3

You need to wrap your calls to .hover() in $(document).ready() calls like you have in some of your other script nodes because the images are not loaded in the page yet when those calls are executed. For example, this:

  $('.s1').hover(
  function () {
    $(this).stop().css('z-index','9998').animate({left:-40});
  },
  function () {
    $(this).stop().css('z-index','').animate({left:-80});
  }
);

should be this:

$(document).ready(function(){
  $('.s1').hover(
  function () {
    $(this).stop().css('z-index','9998').animate({left:-40});
  },
  function () {
    $(this).stop().css('z-index','').animate({left:-80});
  }
);
})

Hope that helps.

Sign up to request clarification or add additional context in comments.

1 Comment

You are welcome! Please accept the answer so the question doesn't show up as "Unanswered".

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.