tryintolearn
tryintolearn

Reputation: 53

background image toggle and hidden select check box

https://jsfiddle.net/dhaileytaha/ghuj4jL8/1/

The above is a fiddle in which i want to toggle or show/hide the background image(i.e. tick mark) onclick and also select the following offer in database (mysql). I am able to show the tick mark but not hide it. Please help.

$(function() {
  $('.listing-content').click(function() {
  $(this).css('background-image', 'url(https://i.sstatic.net/Kg1Do.png)');
 });
})

Upvotes: 0

Views: 109

Answers (2)

krishna
krishna

Reputation: 518

 Here you can use addClass and remove Class method.

you can write a class called "tickMark" in that you give background-image property and you add the class and remove the class dynamically.

https://jsfiddle.net/ghuj4jL8/4/

Upvotes: 0

Rajan Singh
Rajan Singh

Reputation: 631

Updated Fiddle

You can use toggleClass of jQuery for doing that :

Upvotes: 3

Related Questions