0
jquery scrolltopをjquery ajaxハンドルページから使用する方法は?jquery scrolltopをjquery ajaxハンドルページから使用する方法は?
ページaa.html
:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.scrollTo-min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
$.ajax({
url: "bb.php",
dataType: "html",
type: 'POST',
data: "word=hello",
success: function(data){
$("#result").html(data);
}
});
});
</script>
<script type="text/javascript">
jQuery(document).ready(function(){
$(".scrolltoanchor").click(function() {
$.scrollTo($($(this).attr("href")), {
duration: 750
});
return false;
});
});
</script>
</head>
<body id="body">
<div style="padding-top:600px;">jquery scrollto test</div>
<div id="result" style="padding-top:600px;"></div>
<div style="padding-top:600px;">
<a class="scrolltoanchor" href="#body">back to top</a><!-- this can scroll to the top via jquery.scrollTo function -->
</div>
</body>
</html>
ページbb.php
:だから
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<a class="scrolltoanchor" href="#body"><?php echo $_POST['word']; ?>: back to the top</a>!-- this can't scroll to the top via jquery.scrollTo function, just run aa.html?#body as a html anchor -->
</body>
</html>
、それがアニメーションでaa.html
の上部をscrolltoことができるようにbb.php
にscrollTopスプライトを追加する方法?ありがとう。
kingjiv、右、これを忘れて、thx。 – cj333