Do I have to use tags to switch class styles?

< button type= "button" class= "btn btn-primary" > inventory < span class= "glyphicon glyphicon-sort-by-attributes-alt" > < / button >

want to switch from class="glyphicon glyphicon-sort-by-attributes-alt" to class="glyphicon glyphicon-sort-by-attributes" (expected implementation: click the button to switch between two styles)
can it be achieved directly with toggleClass?

Mar.16,2021

Yes, that is, classNameOne is a default style. If you click, use toggleClassTwo to delete or add the class name according to the situation, and then change the style according to the weight. Then one more word, this kind of thing, you will find out by yourself.


two class names can be used with the following code:

if($('button').hasClass('glyphicon-sort-by-attributes-alt')){
    $('button').add('glyphicon-sort-by-attributes').removeClass('glyphicon-sort-by-attributes-alt')
}
else {
    $('button').add('glyphicon-sort-by-attributes-alt').removeClass('glyphicon-sort-by-attributes')
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e590de-454ea.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e590de-454ea.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?