I am making an expand/collapse call rates table for the company I work for. I currently have a table with a button under it to expand it, the button says "Expand". It is functional except I need the button to change to "Collapse" when it is clicked and then of course back to "Expand" when it is clicked again. The writing on the button is a background image.
So basically all I need is to change the background image of a div when it is clicked, except sort of like a toggle.
$('#divID').css("background-image", "url(/myimage.jpg)");
Should do the trick, just hook it up in a click event on the element
$('#divID').click(function() { // do my image switching logic here. });
2.1m questions
2.1m answers
60 comments
57.0k users