how to add and remove class using jquery

Add Remove Class using jquery Name :





 <script>
function addcls(){

 $("#name").attr("class","classname1 classname2");  
}

function removeclass(){
$("#name").removeAttr("class")
}
</script>

Name :
<input type="text" name="name" id="name" value="my name" onclick="(this.value='')" /><br />

<input type="button" onclick="addcls()" value="Add Class"  />
<input type="button" onclick="removeclass()" value="Remove Class"  />


Comments

Popular posts from this blog

Call PHP Function In JavaScript Using Ajax

List of Post Category Wise in wordpress