Change url with jquery

0

I want to change a background image by pressing a input of my web the CSS of the element that I want to press is:

.caldera-grid input[type=radio]{

  background-image:url("http://rentmovers.com/wp-content/uploads/2017/05/bg-form-btn-selected.png");
  background-size:cover;
}

and the code fragment used is

  $('.caldera-grid input[type=radio]').on('click',function(e){
           $(this).css("background-image","http://rentmovers.com/wp-content/uploads/2017/05/bg-form-btn-selected-1.png");
  }); 

apart from more code that is not relevant and does not work any idea?

    
asked by Moisés 29.05.2017 в 18:55
source

1 answer

1

I think you just missed the url ():

$(this).css('background-image', 'url(http://rentmovers.com/wp-content/uploads/2017/05/bg-form-btn-selected-1.png)');

More info: link

    
answered by 29.05.2017 в 18:58