css - using jQuery to change a background image -
i trying use jquery change background image in table cell, table cell has own class of ".active". using jquery change other elements in same place , work fine think must have wrong in syntax. function using executes after button clicked. my code:
function vehicle(arg){ $(".active").css("color", "blue"); $(".active").css("background-image", "url(../img/car.png)"); };
css:
.active{ background-size: 10px 10px; background-repeat: no-repeat; border-right: 1px solid none;
the first line executes fine, have tried following code plus changed picture size in every way can think of :
$(".active").css("background-image", "../img/car.png"); $(".active").css("background-image", "url('../img/car.png')");
can point out did wrong?
you need put .css()
relative page. try:
$(".active").css("background-image", "url('img/car.png')");
assuming img/
in same directory page, should work. else use relative paths root.
Comments
Post a Comment