php - How to set active state for checkbox using JS/jQuery -


i have couple of functions sort property listings php. sorting works, need set active states current active clicked href. of course couldn't lucky set css (although i've included css snippet below reference) attempting jquery have been unsuccessful far.. can find php, jquery, , css below. if can guide me in right direction appreciate help. in advance!

<div>        <?php         foreach( array('desc'=>$main_floor_master) $asc_desc => $asc_desc_name ) {         echo '<a class="filter-checkboxes" href="';          echo add_query_arg( array( 'orderby' => main_floor_master, 'order' => $asc_desc)         );         echo "\">main floor master</a>";         }     ?>        <?php         foreach( array('desc'=>$locality_status) $asc_desc => $asc_desc_name ) {         echo '<a class="filter-checkboxes"  href="';          echo add_query_arg( array( 'orderby' => status, 'order' => $asc_desc)         );         echo "\">quick move in</a>";         }     ?> </div>   <!-- active states --> <script> $(document).ready(function(){      //active state       $(function() {         $('a').click(function(e) {             e.preventdefault();             var $this = $(this);             $this.parent().addclass('active');          });     }); }); </script>   <!-- css --> a.filter-checkboxes {color: #cacaca !important; font-weight: bold; background: url(images/btn-checkboxbg.jpg) no-repeat 0 0; padding-left: 24px; margin-left: 10px;} a.filter-checkboxes:active {color: #cacaca; font-weight: bold; background: url(images/btn-checkboxbg_selected.jpg) no-repeat 0 0; padding-left: 24px; margin-left: 10px;} 

$('a').click(function(e) {     e.preventdefault();     $(this).addclass('active'); }); 

try code above. don't have cache object unless using multiple times in code snippet.

and create css rule for

a.active{ //     // style want active link have } 

note should a.filter-checkboxes.active not a.filter-checkboxes:active

similar question


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -