Javascript 当鼠标单击第一个<;部门>;它必须是向后移动和第二个<;部门>;必须展示
代码:Javascript 当鼠标单击第一个<;部门>;它必须是向后移动和第二个<;部门>;必须展示,javascript,jquery,Javascript,Jquery,代码: 它不起作用;它只移动左侧。您尚未关闭document.ready功能 $(document).ready(function(){ $(div1).mouseover(function(){ $("#div1").animate({right:'2px'}); }); $(div2).mouseover(function(){ $("#div2").animate({right:'2px'}); }); $(div3)
它不起作用;它只移动左侧。您尚未关闭document.ready功能
$(document).ready(function(){
$(div1).mouseover(function(){
$("#div1").animate({right:'2px'});
});
$(div2).mouseover(function(){
$("#div2").animate({right:'2px'});
});
$(div3).mouseover(function(){
$("#div3").animate({right:'2px'});
});
您尚未关闭document.ready函数
$(document).ready(function(){
$(div1).mouseover(function(){
$("#div1").animate({right:'2px'});
});
$(div2).mouseover(function(){
$("#div2").animate({right:'2px'});
});
$(div3).mouseover(function(){
$("#div3").animate({right:'2px'});
});
您尚未关闭document.ready函数
$(document).ready(function(){
$(div1).mouseover(function(){
$("#div1").animate({right:'2px'});
});
$(div2).mouseover(function(){
$("#div2").animate({right:'2px'});
});
$(div3).mouseover(function(){
$("#div3").animate({right:'2px'});
});
您尚未关闭document.ready函数
$(document).ready(function(){
$(div1).mouseover(function(){
$("#div1").animate({right:'2px'});
});
$(div2).mouseover(function(){
$("#div2").animate({right:'2px'});
});
$(div3).mouseover(function(){
$("#div3").animate({right:'2px'});
});
请尝试以下代码:
$(document).ready(function(){
$(div1).mouseover(function(){
$("#div1").animate({right:'2px'});
});
$(div2).mouseover(function(){
$("#div2").animate({right:'2px'});
});
$(div3).mouseover(function(){
$("#div3").animate({right:'2px'});
});
});
$(文档).ready(函数(){
$(div1).mouseover(函数(){
$(“#div1”).animate({右:'10px'});
});
$(div2).mouseover(函数(){
$(“#div2”).animate({右:'8px'});
});
$(div3).mouseover(函数(){
$(“#div3”).animate({右:'6px'});
});
$(div4).mouseover(函数(){
$(“#div4”).animate({右:'4px');
});
$(div5).mouseover(函数(){
$(“#div5”).animate({右:'2px');
});
});
尝试以下代码:
$(document).ready(function(){
$(div1).mouseover(function(){
$("#div1").animate({right:'2px'});
});
$(div2).mouseover(function(){
$("#div2").animate({right:'2px'});
});
$(div3).mouseover(function(){
$("#div3").animate({right:'2px'});
});
});
$(文档).ready(函数(){
$(div1).mouseover(函数(){
$(“#div1”).animate({右:'10px'});
});
$(div2).mouseover(函数(){
$(“#div2”).animate({右:'8px'});
});
$(div3).mouseover(函数(){
$(“#div3”).animate({右:'6px'});
});
$(div4).mouseover(函数(){
$(“#div4”).animate({右:'4px');
});
$(div5).mouseover(函数(){
$(“#div5”).animate({右:'2px');
});
});
尝试以下代码:
$(document).ready(function(){
$(div1).mouseover(function(){
$("#div1").animate({right:'2px'});
});
$(div2).mouseover(function(){
$("#div2").animate({right:'2px'});
});
$(div3).mouseover(function(){
$("#div3").animate({right:'2px'});
});
});
$(文档).ready(函数(){
$(div1).mouseover(函数(){
$(“#div1”).animate({右:'10px'});
});
$(div2).mouseover(函数(){
$(“#div2”).animate({右:'8px'});
});
$(div3).mouseover(函数(){
$(“#div3”).animate({右:'6px'});
});
$(div4).mouseover(函数(){
$(“#div4”).animate({右:'4px');
});
$(div5).mouseover(函数(){
$(“#div5”).animate({右:'2px');
});
});
尝试以下代码:
$(document).ready(function(){
$(div1).mouseover(function(){
$("#div1").animate({right:'2px'});
});
$(div2).mouseover(function(){
$("#div2").animate({right:'2px'});
});
$(div3).mouseover(function(){
$("#div3").animate({right:'2px'});
});
});
$(文档).ready(函数(){
$(div1).mouseover(函数(){
$(“#div1”).animate({右:'10px'});
});
$(div2).mouseover(函数(){
$(“#div2”).animate({右:'8px'});
});
$(div3).mouseover(函数(){
$(“#div3”).animate({右:'6px'});
});
$(div4).mouseover(函数(){
$(“#div4”).animate({右:'4px');
});
$(div5).mouseover(函数(){
$(“#div5”).animate({右:'2px');
});
});
我想我知道你想做什么了。我在JSFIDLE上测试了您的代码,它工作正常,但没有按预期设置动画,因为未设置右侧位置,因此它具有默认的'auto'
,而jQuery在从该位置设置动画时遇到问题
我还建议您设置left
属性的动画:
<script>
$(document).ready(function(){
$(div1).mouseover(function(){
$("#div1").animate({right:'10px'});
});
$(div2).mouseover(function(){
$("#div2").animate({right:'8px'});
});
$(div3).mouseover(function(){
$("#div3").animate({right:'6px'});
});
$(div4).mouseover(function(){
$("#div4").animate({right:'4px'});
});
$(div5).mouseover(function(){
$("#div5").animate({right:'2px'});
});
});</script>
您可以在此处看到演示:
然而,正如您在演示中看到的那样,
正在反复制作动画。这是因为我们在mouseover()
事件上执行它,它似乎不适合您的设计。如果您可以切换到click()
,那么您可以看到一个好结果:我想我知道您想做什么。我在JSFIDLE上测试了您的代码,它工作正常,但没有按预期设置动画,因为未设置右侧位置,因此它具有默认的'auto'
,而jQuery在从该位置设置动画时遇到问题
我还建议您设置left
属性的动画:
<script>
$(document).ready(function(){
$(div1).mouseover(function(){
$("#div1").animate({right:'10px'});
});
$(div2).mouseover(function(){
$("#div2").animate({right:'8px'});
});
$(div3).mouseover(function(){
$("#div3").animate({right:'6px'});
});
$(div4).mouseover(function(){
$("#div4").animate({right:'4px'});
});
$(div5).mouseover(function(){
$("#div5").animate({right:'2px'});
});
});</script>
您可以在此处看到演示:
然而,正如您在演示中看到的那样,
正在反复制作动画。这是因为我们在mouseover()
事件上执行它,它似乎不适合您的设计。如果您可以切换到click()
,那么您可以看到一个好结果:我想我知道您想做什么。我在JSFIDLE上测试了您的代码,它工作正常,但没有按预期设置动画,因为未设置右侧位置,因此它具有默认的'auto'
,而jQuery在从该位置设置动画时遇到问题
我还建议您设置left
属性的动画:
<script>
$(document).ready(function(){
$(div1).mouseover(function(){
$("#div1").animate({right:'10px'});
});
$(div2).mouseover(function(){
$("#div2").animate({right:'8px'});
});
$(div3).mouseover(function(){
$("#div3").animate({right:'6px'});
});
$(div4).mouseover(function(){
$("#div4").animate({right:'4px'});
});
$(div5).mouseover(function(){
$("#div5").animate({right:'2px'});
});
});</script>
您可以在此处看到演示:
然而,正如您在演示中看到的那样,
正在反复制作动画。这是因为我们在mouseover()
事件上执行它,它似乎不适合您的设计。如果您可以切换到click()
,那么您可以看到一个好结果:我想我知道您想做什么。我在JSFIDLE上测试了您的代码,它工作正常,但没有按预期设置动画,因为未设置右侧位置,因此它具有默认的'auto'
,而jQuery在从该位置设置动画时遇到问题
我还建议您设置left
属性的动画:
<script>
$(document).ready(function(){
$(div1).mouseover(function(){
$("#div1").animate({right:'10px'});
});
$(div2).mouseover(function(){
$("#div2").animate({right:'8px'});
});
$(div3).mouseover(function(){
$("#div3").animate({right:'6px'});
});
$(div4).mouseover(function(){
$("#div4").animate({right:'4px'});
});
$(div5).mouseover(function(){
$("#div5").animate({right:'2px'});
});
});</script>
您可以在此处看到演示:
然而,正如您在演示中看到的那样,
正在反复制作动画。这是因为我们在mouseover()
事件上执行它,它似乎不适合您的设计。如果可以切换到click()
,则可以看到一个好结果:使用z-index。单击鼠标在两个分区之间切换z索引。
您可以在鼠标上使用以下代码单击div标记
$('#main > div').mouseover(function () {
$(this).animate({
/* Im getting index value of the hovered div
multiply by 25 (the margin-left differential)
so all div will position on the same spot when animated.
350 is just random you define whatever you like
*/
left: -350-($(this).index()*25)
}).siblings().animate({
left: 0
});
});
使用z索引。单击鼠标在两个分区之间切换z索引。
您可以在鼠标上使用以下代码单击div标记
$('#main > div').mouseover(function () {
$(this).animate({
/* Im getting index value of the hovered div
multiply by 25 (the margin-left differential)
so all div will position on the same spot when animated.
350 is just random you define whatever you like
*/
left: -350-($(this).index()*25)
}).siblings().animate({
left: 0
});
});
使用z索引。单击鼠标在两个分区之间切换z索引。
您可以在鼠标上使用以下代码单击div标记
$('#main > div').mouseover(function () {
$(this).animate({
/* Im getting index value of the hovered div
multiply by 25 (the margin-left differential)
so all div will position on the same spot when animated.
350 is just random you define whatever you like
*/
left: -350-($(this).index()*25)
}).siblings().animate({
left: 0
});
});
使用z索引。单击鼠标在两个分区之间切换z索引。
您可以在鼠标上使用以下代码单击div标记
$('#main > div').mouseover(function () {
$(this).animate({
/* Im getting index value of the hovered div
multiply by 25 (the margin-left differential)
so all div will position on the same spot when animated.
350 is just random you define whatever you like
*/
left: -350-($(this).index()*25)
}).siblings().animate({
left: 0
});
});
是否在脚本中的任何位置定义了/^div[0-9]$/
。。。和显示第二个div。内联样式的可爱用法,尝试使用CSS使代码更具可读性。脚本中是否定义了/^div[0-9]$/
。。。和