jQuery setTimeout 函数不起作用
function zIndex(parcaNumber1, parcaNumber2, Timeout) {
setTimeout(function () {
$(parcaNumber1).css("z-index", "2");
$(parcaNumber2).css("z-index", "1");
}, Timeout);
}
我有一个功能,但不起作用。 怎么了?
function zIndex(parcaNumber1, parcaNumber2, Timeout) {
setTimeout(function () {
$(parcaNumber1).css("z-index", "2");
$(parcaNumber2).css("z-index", "1");
}, Timeout);
}
I have a function, but does not work.
what's wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能您将参数
parcaNumber1
、parcaNumber2
作为字符串传输,但像对象一样调用它:$(parcaNumber1).css("z-index","2");
尝试:
$('.' + parcaNumber1).css("z-index","2");
或
$('#' + parcaNumber1).css("z-index","2");
probably you transfer parameters
parcaNumber1
,parcaNumber2
as string, but call it like an object:$(parcaNumber1).css("z-index","2");
try:
$('.' + parcaNumber1).css("z-index","2");
or
$('#' + parcaNumber1).css("z-index","2");
好吧,不知道你想做什么,但看看这个:我做了一个演示< /a>。
看看它是否是您要找的。不要忘记使用
position:absolute;
设置div
示例:
HTML:
JavaScript:
Well, don't know what you are trying to do, but check this out: I made a demo.
See if it's what you are looking for. Don't forget to set
div
s withposition: absolute;
Example:
HTML:
JavaScript: