Javascript 如何在页面加载时使文本向右滑动?
我的javascript不太流利,我正在尝试编辑,以便在加载页面时,在div幻灯片的右侧(从视图外)平滑地制作一个简单的标题。我只知道这与已经存在的代码有关,但我有两个问题Javascript 如何在页面加载时使文本向右滑动?,javascript,jquery,animation,text,sliding,Javascript,Jquery,Animation,Text,Sliding,我的javascript不太流利,我正在尝试编辑,以便在加载页面时,在div幻灯片的右侧(从视图外)平滑地制作一个简单的标题。我只知道这与已经存在的代码有关,但我有两个问题 当我打开框时,他们正在移动到文本标题中,并将“div”选择器更改为“.headline”(或我命名的任何名称),单击按钮不会移动它 如果我弄明白了,我仍然不知道没有按钮怎么工作 现在,代码是通过单击处理程序调用的,只需删除该代码的包装器,并在页面加载时执行它: $(document).ready(function() {
现在,代码是通过单击处理程序调用的,只需删除该代码的包装器,并在页面加载时执行它:
$(document).ready(function() {
$(".header").animate({ //be sure to change the class of your element to "header"
left:'250px',
opacity:'0.5',
height:'150px',
width:'150px'
});
});
演示:现在代码是通过单击处理程序调用的,只需删除该代码的包装器,并在页面加载时执行它:
$(document).ready(function() {
$(".header").animate({ //be sure to change the class of your element to "header"
left:'250px',
opacity:'0.5',
height:'150px',
width:'150px'
});
});
演示:如果你想在负重时完成,就试试这些 100%工作
html内容和编码如下所示:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
var function1 = function(){
$(document).ready(function(){
$("div").animate({
left:'250px',
opacity:'0.5',
height:'150px',
width:'150px'
});
});
};
</script>
</head>
<body onload="function1();">
<p> in the body tag i have added onload event which tells that when body is fully loaded then do this function which has a name of function1 or you can name something else but remember <b>in script tag the name after var should be same as the name in onload event </b></p>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;">
</div>
</body>
</html>
var function1=function(){
$(文档).ready(函数(){
$(“div”).animate({
左:'250px',
不透明度:'0.5',
高度:'150px',
宽度:'150px'
});
});
};
在body标记中,我添加了onload事件,它告诉我们当body完全加载时,然后执行这个名为function1的函数,或者您可以命名其他名称,但请记住,在script标记中,var后面的名称应该与onload事件中的名称相同
如果你想在身体负重时完成,就试试这些
100%工作html内容和编码如下所示:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
var function1 = function(){
$(document).ready(function(){
$("div").animate({
left:'250px',
opacity:'0.5',
height:'150px',
width:'150px'
});
});
};
</script>
</head>
<body onload="function1();">
<p> in the body tag i have added onload event which tells that when body is fully loaded then do this function which has a name of function1 or you can name something else but remember <b>in script tag the name after var should be same as the name in onload event </b></p>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;">
</div>
</body>
</html>
var function1=function(){
$(文档).ready(函数(){
$(“div”).animate({
左:'250px',
不透明度:'0.5',
高度:'150px',
宽度:'150px'
});
});
};
在body标记中,我添加了onload事件,它告诉我们当body完全加载时,然后执行这个名为function1的函数,或者您可以命名其他名称,但请记住,在script标记中,var后面的名称应该与onload事件中的名称相同
您可以详细说明它们如何/为什么以这种方式工作,可能是JSFIDLE。您可以详细说明它们如何/为什么以这种方式工作,可能是JSFIDLE。