Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery CSS操作_Jquery_Css - Fatal编程技术网

Jquery 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'); }); }); 一开始,我认为您想要的是$(),而

我想在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');
});
});

  • 一开始,我认为您想要的是
    $(
    ),而不是
    $(
  • 在第二行的末尾,我想您需要另一个嵌套函数:
    .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");          
          }     
          );
    });