bbtron bbtron - 1 month ago 5x
CSS Question

edit css to

I am trying to make background change CSS attribute to
and it is not working. All the commands are working except changing

Here is the code I'm using:

$(document).ready(function() {
$(".plusMatch").click(function(event) {

if ($("#productImage""visible")) {
$("#productImage""display", "none");
$("#productImage"'visible');"background", "url(minusSign.jpg)");

} else {
$("#productImage""display", "block");
$("#productImage"'visible');"background", "url(minusSign.jpg)");



The first thing is that you are using JQuery in your project, so it is better for you to write $( instead of if you want to use the JQuery CSS property.

Then, to change any CSS property with javascript, you have two options :

The native style property will edit the style tag on your HTML element, for example : = 'url(myPicture.jpg)';

More informations

The JQuery css property

$('background': 'url(myPicture.jpg)');

More informations

Both of these solutions will produce the following result :

<div style="background:url('myPicture.jpg');"></div>