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
https://forums.phpfreaks.com/topic/241666-jquery-question/
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
https://forums.phpfreaks.com/topic/241666-jquery-question/#findComment-1241211
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
https://forums.phpfreaks.com/topic/241666-jquery-question/#findComment-1241567
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.