tags:

views:

109

answers:

3

I have a li element like this:

    <li class="file file-success">
    </li>

I want to change its background using jQuery.

Note that I can't change the li element itself.

+1  A: 

You could use:

$("li.file").css("background-color", "#ff0000");

or

$("li.file-success").css("background-color", "#ff0000");

depending on what CSS selector you want to use for this.

richsage
+2  A: 

Do you want to change li text color or bullet color? The former can be achieved through this code:

$('li.file').css('background-color', 'yellow'});

If you want to change bullet image, here is the code:

$('li.file').css('list-style-image', 'url(yourimage.jpg)'});
Mohsen
i want to change its background with other image
air
You can change bullet image with list-style-image property. I've added necessary code to change it programatically.
Mohsen
+1  A: 
$("li.file").css("background-image", "url(test.png)");
Eric
If you add a background image, you may also need to define it's height and width as well, in case the text contained in the li is too short
fudgey