Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
jQuery . fn . myToggleClass = function ( firstClass, secondClass ){
return this . each(function(){
var $t = $( this );
if ( !$t . hasClass( firstClass ) ){
if( $t . hasClass( secondClass ) ) removeClass( secondClass );
$t . addClass ( firstClass );
}else{
$t . removeClass( firstClass ) . addClass( secondClass );
}
});
}
Не,така нали премахва класа и после го добавя т.е не става нищо.F1r3Fl3x каза:Ако е за всички инпут полета, ще изглежда по подобен начин:
Код:jQuery('input').click(function(){ jQuery('input').removeClass('clicked'); jQuery(this).addClass('clicked'); });![]()
като си добавиш двата класа clicked и notclicked в CSS$(document).ready(function(){
$("#myform input").click(function(){
$("#myform").find('.clicked').removeClass('clicked');
$(this).addClass('clicked');
});
});