How do I toggle CSS with jQuery?

Posted by marcamillion on Stack Overflow See other posts from Stack Overflow or by marcamillion
Published on 2010-12-22T21:08:46Z Indexed on 2011/01/12 7:53 UTC
Read the original article Hit count: 248

Filed under:
|
|

I have the following code:

$('#bc' + $.trim($this) + ' span.dashed-circle').css({ 'border' : '5px solid #000'});

That is triggered by a click.function().

I would like that to be a toggle - so when I click the element, it changes the border to what I have above...but when it is clicked again it disappears or rather sets the border to ' '.

Thoughts?

Edit: I should have been explicit...but I don't want to create a CSS class. The reason being is because when I do that, it messes up the formatting of the element being styled. I am sure that it is some small quirk somewhere that would fix it, but I am not interested in wading through the entire code base to fix little positioning issues with a new class. I would much rather just edit the css attribute directly - because it doesn't interfere with the layout.

Edit2: Here is the jsfiddle of the code I am trying to edit. If you notice, I have the CSS attributes last. But how do I let that be toggled ?

Edit3: If anyone is interested...the UI that this will be used in is for my webapp - http://www.compversions.com

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html