Here is my code:
var showThis = $(this).attr('id'); // div0, div1, div2 etc.
$('#' + showThis).attr('style', 'background-color: #063 !important, height: 520px');
I need the change the background-color, width and height of
#showThis
using the method used above since I cannot add or switch Classes (it breaks the rest of my code if I add a class to #showThis). Now what I have above works, however, it only changes the background-color height. I need to change the width as well. When I add
width: 20px
like so
at the end of it, it doesn't work for some reason. It stops changing both the width and height, changes the background-color. It doesn't give any javascript errors so the code works and the line does execute since it does change the background-color, but how come it doesn't change the width and height yet it only changes the one of the two?
Note: I need to use the !important tag (so I don't think .css instead of .attr works) and I am using I.E 8 and CSS (Not css3) if it helps.
$('#' + showThis).css({'background-color': '#063', 'height': '520px'}), etc. In my opinion, it would be much easier to just toggle a class with the predefined styles.$(this)and$('#' + $(this).attr('id'))should select the same element, no?