Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将jQuery函数更改为页面加载_Javascript_Jquery - Fatal编程技术网

Javascript 将jQuery函数更改为页面加载

Javascript 将jQuery函数更改为页面加载,javascript,jquery,Javascript,Jquery,谁能告诉我如何将下面的语句(当前由单选按钮控制)更改为文档加载功能 基本上,当页面加载时,我希望幻灯片div从左向右滑动。 jQuery: HTML: $document.ready{.Your staff.} 一种方法是在加载时单击它,就像$'input[name=radiobutton]'一样;或$'input[name=radiobutton]'。触发“单击” 另一种方法是将代码放在函数中,并在加载时调用该函数 function showSomething(){ // code he

谁能告诉我如何将下面的语句(当前由单选按钮控制)更改为文档加载功能

基本上,当页面加载时,我希望幻灯片div从左向右滑动。 jQuery:

HTML:


$document.ready{.Your staff.}

一种方法是在加载时单击它,就像$'input[name=radiobutton]'一样;或$'input[name=radiobutton]'。触发“单击”

另一种方法是将代码放在函数中,并在加载时调用该函数

function showSomething(){
   // code here
}

showSomething();

ready是一种javascript的onload,它等待一切就绪,然后执行……您的代码,它是安全的,也是onload的最佳实践

$(document).ready(function() {
    $("divid").animate({top:'10px', bottom:0}, 3000);
    });

@NewB我刚刚移动了代码…在document.ready中,您可以按照您想要的方式对其进行优化…我们越来越接近了,但我想去掉所有的值,我只想在页面加载时将div滑出,并且不依赖于任何内容。@enewB使您的div处于相对位置,然后使用jquery中的animate函数,您可以在那里制作所有出色的动画…获取偏移位置并开始动画,并在某个像素后停止。它应该向前移动。您可以尝试此链接以获取滑动示例:
function showSomething(){
   // code here
}

showSomething();
$(document).ready(function() {
    $("divid").animate({top:'10px', bottom:0}, 3000);
    });