jquery - Active & Inactive class add & remove -


i need add & remove class on click of anchor tag.

 <div class="activetab">     <a href="#." class="active">active</a>     <a href="#.">inactive</a> </div> 

above div has 2 anchor tags & "active" & "inactive" 1 has class 'active'. requirement need remove 'active' class on click of "inactive" anchor tag & add class 'active' clicked "inactive" anchor , if clicked on "active" anchor again class remove form "inactive" anchor & add "active" anchor. jquery.

if undestood well...

i made refork of old lil snippet doing want (or guess want) xdd

sorry english, it's hard me write on it.

html

<div class="container">    <div class="activetab">       <a href="#." class="button_active">active</a>       <a href="#." class="button_inactive">inactive</a>   </div>  </div> 

css

.activetab { width:100%; padding:30px 0 20px 0; background:#fff; }  .active { background: #f0f0f0; } 

js

$(function() { $( ".button_active" ).click(function() {  $( ".activetab" ).addclass("active");  return false; }); });  $(function() { $( ".button_inactive" ).click(function() {  $( ".activetab" ).removeclass("active");  return false; }); }); 

you can see working demo on jsfiddle http://jsfiddle.net/aritz81/74bge/1/


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -