Jquery CSS操作
我想在hover-like上更改div的css属性Jquery CSS操作,jquery,css,Jquery,Css,我想在hover-like上更改div的css属性 $(function(){ $("div#box").hover({ $("div#box").css({z-index:'12'}); }); }); Dreamweaver给了我一个语法错误。谁能告诉我是什么问题吗?试试这个 $(function(){ $("div#box").hover(function(){ $("div#box").css('z-index', '12'); }); }); 一开始,我认为您想要的是$(),而
$(function(){
$("div#box").hover({
$("div#box").css({z-index:'12'});
});
});
Dreamweaver给了我一个语法错误。谁能告诉我是什么问题吗?试试这个
$(function(){
$("div#box").hover(function(){
$("div#box").css('z-index', '12');
});
});
$(
),而不是$(
).hover(function(){
而不是.hover({
)。实际上,您正在创建一个对象文本,我认为这不是您想要的总之,我刚刚评论了如何使用动画和类
$(document).ready(function() {
$('div#box').hover(
function(){
$("div#box").css({zIndex:'12'});
//$(this).find('img').animate({opacity: ".6"}, 300);
//$(this).find('.caption').animate({top:"-85px"}, 300);
//$(this).removeClass().addClass("someClassName");
},
function(){
$("div#box").css({zIndex:''});
//$(this).find('img').animate({opacity: "1.0"}, 300);
//$(this).find('.caption').animate({top:"85px"}, 100);
//$(this).removeClass().addClass("someClassName");
}
);
});
css
调用不需要更改——它可以接受一个映射(对象文字)。@JoeWhite-我认为它需要是一个字符串。({zIndex:12}
可以工作,)啊,是的,你说得对,它需要一个字符串(因为z-index
中的连字符)我只注意到你把它从map重载改成了two string重载——我没有注意到你在z-index
$(function(){$(“div#box”).hover(function(){$(“div#box”).css({z-index',12})})周围加引号的地方;它仍然在.css行上出现语法错误。谢谢,这非常有效。我希望对于borderBottom之类的属性,它也是如此?
$(document).ready(function() {
$('div#box').hover(
function(){
$("div#box").css({zIndex:'12'});
//$(this).find('img').animate({opacity: ".6"}, 300);
//$(this).find('.caption').animate({top:"-85px"}, 300);
//$(this).removeClass().addClass("someClassName");
},
function(){
$("div#box").css({zIndex:''});
//$(this).find('img').animate({opacity: "1.0"}, 300);
//$(this).find('.caption').animate({top:"85px"}, 100);
//$(this).removeClass().addClass("someClassName");
}
);
});