1
  .button {
        background: transparent url("/assets/LoD-Button-Normal.png") no-repeat bottom right;
        width: 110px;
        height: 30px;
        display: block;
        background-position: bottom right; 
        text-align:center;
    }

    .button_click { 
      background: transparent url("/assets/LoD-Button-Click.png") no-repeat bottom right;
      width: 110px;
      height: 30px;
      display: block;
      background-position: bottom right;
    }

    $(".button").click(function(){
      $(this).removeClass("button").addClass("button_click");   
    })

    <a class="button" href="/link"> Button </a>

ボタンをクリックしたとき。Firefox では背景画像を変更しますが、Chrome では機能しません。私を助けてください

4

1 に答える 1

2

コードは問題ないように見えるので、bg 画像を変更する前にクロムがリダイレクトしている可能性があるエラーはありません。

これを試して:

$(".button").click(function(e){
  e.preventDefault();
  $(this).removeClass("button").addClass("button_click");
  location.href = $(this).attr('href'); 
  // if for some reason this isn't working you can call setTimeout with the location.href
});
于 2012-06-10T14:54:30.953 に答える