Jump to content

jquery question


purencool

Recommended Posts

hi phpfreaks

 

I am using jquery 1.6.2. I am tryng to get a div to move with another element on the page the code below is what I have created but

it will not work. If I press on the button it always give is me a number. but I can't get the element to move. I am new

to jquery so this could be complete wrong. Anyone got any ideas?

 

// onload  do the following
$(document).ready(function(){
          // get image to move
  var image = $("#content-image");
         // access its position  variable
  var contentImage = image.position();
          // make div top =  scrollbar position
  contentImage.top = $(".jquery-wrapper").scrollTop();

  $("button").click(function(){
	  alert($(".jquery-wrapper").scrollTop()+" px");  
  });
});

Link to comment
Share on other sites

$(document).ready(function(){
          // get image to move
  var image = $("#content-image");
         // access its position  variable
  var contentImage = image.position();
          // make div top =  scrollbar position
  contentImage.top = $(".jquery-wrapper").scrollTop();

  $("button").click(function(){
	  $(".jquery-wrapper").scrollTop(-500);
  });
});

Link to comment
Share on other sites

thanks for the response sorry I must not described it properly. I have got two div's side by side and when I scroll down the page I want the  image in the right hand column to move down the page. so it never is out of site. #content-image top is suppose to  move the image up and down the column with the scrolling. The button was to prove  $(".jquery-wrapper").scrollTop(); was giving a value.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.