【问题标题】:How can I set the important flag in a css with jQuery? [duplicate]如何使用 jQuery 在 css 中设置重要标志? [复制]
【发布时间】:2012-09-03 02:26:17
【问题描述】:

可能重复:
Jquery css: applying !important styles

我有以下代码:

$("body")
    .ajaxStart(function () {
        $(this).css({ 'cursor': 'progress' })
    })
    .ajaxStop(function () {
        $(this).css({ 'cursor': 'default' })
    });

这有效,但当我将鼠标悬停在有悬停和不同光标的链接上时无效。有没有一种方法可以使用 jQuery>

将上面的 CSS 光标属性设置为重要

【问题讨论】:

    标签: jquery css


    【解决方案1】:

    试试这个代码,例如:

    $(this).css({ 'cursor': 'default !important' })
    

    【讨论】:

      【解决方案2】:
      $("body")
      .ajaxStart(function () {
          $(this).css({ 'cursor': 'progress !important' })
      })
      .ajaxStop(function () {
          $(this).css({ 'cursor': 'default !important' })
      });
      

      【讨论】:

      • 我没有投反对票,但我猜是因为其他答案说 !important 存在问题。我仍在查看所有链接。
      • @SamanthaJ 我没问题。所有其他答案和我的答案有什么不同..解释
      【解决方案3】:

      【讨论】:

      • 这与其他答案有何一致?现在我有点迷茫了。
      • 你需要添加你的style函数的实现..
      • jQuary 没有方法style 你能确认你的来源或给我们演示吗?
      • 我试图发布链接,现在更正了
      【解决方案4】:

      只需在您的属性值后添加!important

      $("body")
          .ajaxStart(function () {
              $(this).css({ 'cursor': 'progress !important' })
          })
           .ajaxStop(function () {
              $(this).css({ 'cursor': 'default  !important' })
         });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-12-19
        • 1970-01-01
        • 2014-01-22
        • 2020-07-16
        • 1970-01-01
        • 2013-02-10
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多