"Toggle Class"
Bootstrap 3.1.0 Snippet by wag0325

<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <p class="blue">Click to toggle</p> <p class="blue highlight">highlight</p> <p class="blue">on these</p> <p class="blue">paragraphs</p>
p { margin: 4px; font-size: 16px; font-weight: bolder; cursor: pointer; } .blue { color: blue; } .highlight { background: yellow; }
$( 'p' ).click(function() { if( $ ('p').hasClass('highlight') ){ $( 'p' ).removeClass( 'highlight' ); } else{ $( 'p' ).addClass( 'highlight' ); } });

Related: See More


Questions / Comments: