嘿.我想将一个变量作为参数传递给第n个子选择器.
这不起作用:
var position = 5;
$("#daddy > div:nth-child(position)").animate({
opacity: 0.01,
}, 500);?
Run Code Online (Sandbox Code Playgroud)
虽然可以吗?干杯,杰克
我试图在它定义的函数之外使用一个变量值.思想I.只需要在函数外部声明变量但不会削减它.对于那些知道的人来说,要轻松一点吗?
在这里小提琴
jQuery(document).ready(function() {
var readOut;
var readOut2;
$(document).mousemove(function(e) {
readOut1 = e.pageX;
readOut2 = e.pageY;
$('#var1').html(readOut1);
});
$('#var2').html(readOut2);
})?
Run Code Online (Sandbox Code Playgroud)
感谢所有人,特别是Andy E的解释和解决方案.
我有一个很好看的花哨脚本,但不是必不可少的惊喜,不能与IE玩得很好.我怎么'为IE评论'?
我知道我可以使用以下内容包含 IE语句,但如何排除它们?
<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->
Run Code Online (Sandbox Code Playgroud) 有人可以解释这个片段有什么问题吗?
我想要获得div中所有图像的宽度.
var totalwidth = $("#imagecontainer > img").width();
$("#imagecontainer").width(totalwidth);
Run Code Online (Sandbox Code Playgroud)
对不起,以为这只是一个语法问题(联合国)工作示例:
http://jsfiddle.net/TZ2nT/3/
容器div由于某种原因不接受该值?
我正在尝试编写一些代码来打印div中包含的所有图像的尺寸,这很简单,因为它似乎无法让它工作.有人能指出这里的错误吗?谢谢!
$(document).ready(function() {
var width = 0;
var height = 0;
var hello = "hello";
$('#imagebox img').each(function(){
width = $(this).width;
height = $(this).height;
$('#main').append(hello);
$('#main').append(width);
$('#main').append(height);
});
});
Run Code Online (Sandbox Code Playgroud)