javascript - 帮助 ajax jquery css 事情

标签 javascript css ajax

谁能快速浏览一下这段代码,让我知道哪里出错了。

在模糊事件中,.textok 类加载正常,但 .textbad 类加载不正常。

<style>
   .textok {
color:#0F0;
background-color:#093;
};
.textbad {
color:#F00;
background-color:#900;
 };
  </style>

 <script>

$("#name").blur(function()
{
$.post("logval.php?type=name",{ name:$('#name').val() } ,function(data)
    {
      if(data=='noname') //if no username
      {
      $("#usererror").fadeTo(200,0.1,function() //start fading the messagebox
            {
              //add message and change the class of the box and start fading
              $("#usererror").html('Name Accepted      ').addClass("textbad").fadeTo(900,1);
              $("#tic").attr("src","tic.gif").fadeTo(900,1);
            });
      } else 
      {
      $("#usererror").fadeTo(200,0.1,function() //start fading the messagebox
            {
              //add message and change the class of the box and start fading
              $("#usererror").html('Name Accepted  ').addClass("textok").fadeTo(900,1);
              $("#tic").attr("src","tic.gif").fadeTo(900,1);
            });
      }
    });
})




     </script>

最佳答案

在 CSS 中不要在大括号后加上分号:

.textok {
    color:#0F0;
    background-color:#093;
} /* No semicolon here! */

正是这些分号阻止了您的 CSS 被理解。

关于javascript - 帮助 ajax jquery css 事情,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7000654/

相关文章:

javascript - 如何在 JavaScript 中实现 PBEWithMD5AndDES 算法?

javascript - Jquery 记住添加的输入字段

javascript - HTML中通过JS将图片的src赋值给变量

html - 当 flexbox 元素以列模式包装时,容器不会增加其宽度

c# - 如何使用一些变量参数从 javascript 函数调用 asp.net C# 函数并从 C# 函数获取字符串返回?

javascript - Angular foreach 循环不提供使用 break 或 return 来中断循环的便利。但为什么?

html - 如何溢出 3 级深度菜单 ul > li > ul > li > ul > li

javascript - 菜单栏,它不在顶部,但是一旦向下滑动菜单栏就会粘在顶部

php - 项目研究 - 可缩放、可滚动、可悬停的高分辨率图像

javascript - 为什么 .innerHTML 在 xmlhttp.open() 和 .send() 之前更改?