javascript - remove active class from current div when clicking siblings in JQuery -
i trying remove active
class current div when of sibling divs clicked.
for reason that's not working in case.
i'll grateful help.
below html , js (notice section question selected, , active)
<div class="question"> <div class="views-field views-field-title views-accordion-header ui-accordion-header ui-state-default ui-corner-all ui-accordion-icons" role="tab" id="ui-id-9" aria-controls="ui-id-10" aria-selected="false" aria-expanded="false" tabindex="-1"> <span class="ui-accordion-header-icon ui-icon ui-icon-triangle-1-e"></span> <a href="#q_as-page-4"> <span class="field-content">ex valde </span> </a> </div> <div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" id="ui-id-10" aria-labelledby="ui-id-9" role="tabpanel" aria-hidden="true" style="display: none; height: 643.801979064941px;"> <div class="views-field views-field-body"> <div class="field-content">blandit immitto iusto natu praesent turpis. dolore duis ideo meus nimis venio vulpes. @ autem commodo dignissim interdico mos vel. eros letalis nobis quia secundum. decet metuo neque. causa incassum lobortis pecus quadrum qui tamen.</div> </div> </div> </div> <div class="question active"> <div class="views-field views-field-title views-accordion-header ui-accordion-header ui-state-active ui-corner-all ui-accordion-icons" role="tab" id="ui-id-11" aria-controls="ui-id-12" aria-selected="false" aria-expanded="false" tabindex="-1"> <span class="ui-accordion-header-icon ui-icon ui-icon-triangle-1-e"></span> <a href="#q_as-page-5"> <span class="field-content">cogo ibidem persto zelus </span> </a> </div> <div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" id="ui-id-12" aria-labelledby="ui-id-11" role="tabpanel" aria-hidden="true" style="display: none; height: 643.801979064941px;"> <div class="views-field views-field-body"> <div class="field-content">eu hendrerit pala ulciscor. exputo gilvus tincidunt. exputo nutus obruo paulatim secundum tation torqueo. defui esse ille iriure lucidus mauris roto. </div> </div> </div> </div> <div class="question"> <div class="views-field views-field-title views-accordion-header ui-accordion-header ui-state-default ui-corner-all ui-accordion-icons" role="tab" id="ui-id-13" aria-controls="ui-id-14" aria-selected="false" aria-expanded="false" tabindex="-1"> <span class="ui-accordion-header-icon ui-icon ui-icon-triangle-1-e"></span> <a href="#q_as-page-6"> <span class="field-content">cogo ibidem persto zelus </span> </a> </div> <div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" id="ui-id-14" aria-labelledby="ui-id-13" role="tabpanel" aria-hidden="true" style="display: none; height: 643.801979064941px;"> <div class="views-field views-field-body"> <div class="field-content">eu hendrerit pala ulciscor. exputo gilvus tincidunt. exputo nutus obruo paulatim secundum tation torqueo. defui esse ille iriure lucidus mauris roto. </div> </div> </div> </div>
js
$('.question .ui-state-default a').on("click", function(e) { //$(this).parent().parent().closest('div[class=active]').removeclass("active");; //$(this).parent().parent().parent().removeclass("active"); $(this).parent().parent().addclass("active"); });
try this:
$('.question .ui-state-default a').on("click", function(e) { $(".question").removeclass("active"); $(this).parent().parent().addclass("active"); });
Comments
Post a Comment