Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7709405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:51:13+00:00 2026-06-01T00:51:13+00:00

i have one image in my html and i have 5 different link, i

  • 0

i have one image in my html and i have 5 different link, i want to change image background position using only one class, so i set parameters in function but it is not working ?

<head>

<script type="text/javascript" src="jquery-1.7.min.js"></script>

<script type="text/javascript">

$(function Bg(left,top) {

    $('.me').each(function (){
        $(this).hover(function(){
            $('.container').css({backgroundPosition: left+ 'px', top + "px"})

            })

        })

    })




</script>
<style>

.container { width:100px; height:100px; float:left; background:url(../bike.jpg) left top no-repeat;}
</style>

</head>

<body>
<a href="#" class="me" onmouseover="Bg(50,60)">click me1</a>
<a href="#" onmouseover="Bg(80,70)" class="me">click me2</a>
<a href="#" onmouseover="Bg(120,60)" class="me">click me3</a>
<a href="#" onmouseover="Bg(150,60)" class="me">click me4</a>

<div class="container"></div>

</body>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:51:14+00:00Added an answer on June 1, 2026 at 12:51 am

    That code won’t work. You have the values stored inline in the href attribute of each <a> and you never call the function itself.

    You should move the background position in a data attribute like: data-bg="x,y" then use this adapted code:

       $(function() {
        $('.me').each(function (){
            $(this).on('hover', function(){
                 var bgPos = $(this).attr('coords');            
                 bgPos = bgPos.split(',');   
                 $('.container').css(
                      'background-position', bgPos[0] + 'px ' + bgPos[1] + 'px');
                });
            });
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My scenario: I have one color background image JPG. I have one black text
Okay, I have two different background .jpgs that I want to used as the
I have the following snippet in one of my html pages : <div class=inputboximage>
I have some static resources (images and HTML files) that will be localized. One
I have one image submit button like this <input id=enter name=enter type=image value=Login src=images/btn_login.jpg/>
I have a small flash file that just loads and shows one image scaled
I have one app, a UIImage* . I'm painting the image twice: Once in
I re-image one of my machines regularly; and have a script that I run
I have a Grid which contains an Image in one of its columns. The
If I have a button like the one in this image : http://www.freeimagehosting.net/image.php?4cd775814c.png how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.