嗨,我累了谷歌搜索jQuery 1.7 API文档文件.有人请给我一个链接,在那里我可以离线jQuery 1.7 api转储.
谢谢
我有一个背景图像的DIV.但我的要求是如何根据背景图像的高度和宽度扩展DIV大小.我已经在这个链接的帮助下尝试了一些代码.
var src = $('#divID').css('background-image').
replace('url', '')
.replace('(', '')
.replace(')', '')
.replace('"', '')
.replace('"', '');
$('body').append('<img id="appendedImg" src="' + src + '" style="height:0px;width:0px"');
var img = document.getElementById('appendedImg');
var width = img.clientWidth;
var height = img.clientHeight;
$('#appendedImg').detach();
Run Code Online (Sandbox Code Playgroud)
我正在寻找任何优雅的解决方案,如果可能的话.
根据下面的jQuery文档,代码可用于捕获mouseup和mouse down事件.但我的要求有点不同
$("#dic").mouseup(function () {
}).mousedown(function () {
});
Run Code Online (Sandbox Code Playgroud)
但是如何计算mousedown位置与mouseup位置之间的鼠标移动坐标.请帮帮我.如何在mousedown和mouseup之间应用mousemove事件
我试图使用下面的代码将DIV置于屏幕中心,但它对我不起作用.有人请建议我让它工作
var hnw = {};
hnw.w = 0;
hnw.h = 0;
if (!window.innerWidth) {
if (!(document.documentElement.clientWidth == 0)) {
hnw.w = document.documentElement.clientWidth;
hnw.h = document.documentElement.clientHeight;
}
else {
hnw.w = document.body.clientWidth;
hnw.h = document.body.clientHeight;
}
}
else {
hnw.w = window.innerWidth;
hnw.h = window.innerHeight;
}
var midEle = document.createElement('div');
var _x = 0;
var _y = 0;
var offsetX = 0;
var offsetY = 0;
if (!window.pageYOffset) {
if (!(document.documentElement.scrollTop == 0)) {
offsetY = document.documentElement.scrollTop;
offsetX = document.documentElement.scrollLeft;
} …Run Code Online (Sandbox Code Playgroud) 我试图将值推送到数组的属性,如下所示
var obj = {};
obj.a = (obj.a || []).push(10);
console.log( typeof obj.a ); // Returning number
Run Code Online (Sandbox Code Playgroud)
如何纠正这个以将obj.a保持为数组?
在Pro JavaScript with Mootools一书中,我找到了以下内容
The scoping rules for function expressions are a bit different from function
declarations because they depend on variable scoping. Remember that in
JavaScript, the var keyword defines a variable to be scoped locally, and
omitting the keyword creates a global variable instead:
Run Code Online (Sandbox Code Playgroud)
根据我的理解,我写了下面的代码,并试图检查这一点
var a = function(){
b = function(){ c = function(){ alert("b"); }; };
};
alert(typeof a); // Returned me 'function'
alert(typeof b); // Returned me 'undefined'
alert(typeof c); // Returned me 'undefined'
Run Code Online (Sandbox Code Playgroud)
我也在下面尝试过 …
AFAIK我们无法访问从不同域加载的iframe的DOM内容.但在我的情况下,我有一个名称如下的网站
http://dom1.myMainDomain.com/******
Run Code Online (Sandbox Code Playgroud)
在该页面中,我将一个来自子域的HTML文件加载到上述网站中的Iframe,该网站是如上所述的子域.即
http://dom2.myMainDomain.com/******/1.html
Run Code Online (Sandbox Code Playgroud)
我试过下面的代码,但它不起作用
$(document).ready(function () {
var str = "http://dom1.myMainDomain.com/*****Images/";
$('body').append('<iframe id="ifr" style="position:absolute;top:0px;left:0px;width:100%;height:100%" src="' + str + $('#htmNum').val() + '.html"></iframe>');
document.domain = "myMainDomain.com";
$('#ifr').load(function () {
$('#ifr').contents().find('body').html('Hey, i`ve changed content of <body>! Yay!!!');
});
});
Run Code Online (Sandbox Code Playgroud)
但它对我不起作用..我嵌入上述代码的网站是
http://dom2.myMainDomain.com/*****.aspx
Run Code Online (Sandbox Code Playgroud)
Please help me on this. As per the answer I have tried and it was working in IE7./ But in Chrome I can see permission denied message
我有这样的数组
[0,2,3]
Run Code Online (Sandbox Code Playgroud)
这个阵列可能的改组是
[0,2,3], [2,3,0], [3,0,2], [3,2,0], [0,3,2], [2,0,3]
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得这些组合?我目前唯一的想法是
n = maximum num of possible combinations, coms = []
while( coms.length <= n )
temp = shuffle( original the array );
if temp is there in coms
return
else
coms.push(temp);
Run Code Online (Sandbox Code Playgroud)
但我不认为这是有效的,因为我们盲目地依赖于随机方法的均匀分布.
这个问题有替代发现吗?
$('.pallete').hide();
$(document).delegate('.pick', 'click', function () {
var pos = $(this).offset();
var x = pos.left - $(window).scrollLeft() + $(this).width();
var y = pos.top - $(window).scrollTop() + $(this).height();
$('.pallete').css({
top: y + "px",
left: x + "px",
}).show();
});
$(document).delegate('.col', 'click', function () {
var pos = $(this).css('background-color');
$('.pick').css('background-color', pos);
$(this).parents('div').fadeOut();
});
Run Code Online (Sandbox Code Playgroud)
这是小提琴,http://jsfiddle.net/zPNk3/5/.问题是,当我第一次点击.pick元素时,'.palette'元素被正确显示.但是当我下次点击同样不起作用时.
我有一个存储在变量中的日期,如下所示
var date = moment(new Date()).valueOf();
Run Code Online (Sandbox Code Playgroud)
我需要像下面那样格式化它
CCYY-MM-DDTHH:MM:SS [.sss] TZD
时区定义是强制性的,必须是UTC(通过在字符串末尾添加字符'Z'表示)或与UTC的某些偏移(通过添加'[+ | - ]'和'hh:mm表示'到字符串的末尾).
我尝试过如下
var required = moment.utc(date).format('CCYY-MM-DDThh:mm:ss[.sss]TZD')
Run Code Online (Sandbox Code Playgroud)
但结果如下
"CC14-06-03T07:59:15.sssT+00:003"
Run Code Online (Sandbox Code Playgroud)
但预期的格式示例是
UTC :
1969-07-21T02:56:15Z
Houston time :
1969-07-20T21:56:15-05:00
Run Code Online (Sandbox Code Playgroud)