bbtron bbtron - 1 year ago 150
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)");


Answer Source

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> 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download