2017-11-04 13 views
2

このコード内で、 "play.png"画像を配置する背景位置を追加する正しい方法は何ですか?jqueryコードの背景位置

jQuery(document).ready(function($) { 
     var audioElement = document.createElement('audio'); 
    $(".audioplay img").click(function() { 
    audioElement.setAttribute('src', $(this).attr('data-href')); 
    if($(this).hasClass('playing')){ 
     $(this).attr("src","/wp-content/player/play.png"); <<<<<< BACKGROUND POSITION 
     $('.audioplay img').removeClass("playing"); 
     audioElement.pause(); 
    }else{ 
     $('.audioplay img').removeClass("playing"); 
     $('.audioplay img').attr("src","/wp-content/player/play.png"); 
     $(this).attr("src","/wp-content/player/stop.png"); 
     $(this).addClass("playing"); 
     audioElement.play(); 
    } 

    }); 
}); 

答えて

0

juqery

$(this).css('background-position', '10px 10px'); 

、あなたは、こんにちは

$(this).css('background-position', ''); 
+0

あなたが助けに感謝をBGの位置を削除したい場合は経由してCSSを追加してみてください;) – user7082272

+1

はい、これは働いていました。ありがとうございました! ;) – user7082272

+0

私の答えの近くのチックをクリック&緑にする..答えとしてそれを受け入れる...&評判を得る:) –