Postingan lainnya
Kelas Premium!
Belajar bikin website dari nol sekarang
Gunakan kupon "lebihcepat" untuk diskon 25%!
Kelas Premium!
Belajar Javascript untuk website
Gunakan kupon "mulaijs" untuk diskon 75 ribu!
Bagaimana cara mengganti value dari atribut class menggunakan Javascript atau Jquery?
Misal saya punya tombol
<button class="tombol">
<i class="fas fa-eye"></i>
</button>
Nah, setelah tombol di klik, saya ingin mengganti class "fa-eye" menjadi class "fa-eye-slash"
1 Jawaban:
<div>pakai jquery<br><figure data-trix-attachment="{"contentType":"image/png","filename":"jQ_ElmAttClass.png","filesize":43235,"height":528,"url":"https://i.ibb.co/Cm2T488/j-Q-Elm-Att-Class.png","width":856}" data-trix-content-type="image/png" data-trix-attributes="{"presentation":"gallery"}" class="attachment attachment--preview attachment--png"><img src="https://i.ibb.co/Cm2T488/j-Q-Elm-Att-Class.png" width="856" height="528"><figcaption class="attachment__caption"><span class="attachment__name">jQ_ElmAttClass.png</span></figcaption></figure><br><br>pakai vanila javascript<br><figure data-trix-attachment="{"contentType":"image/png","filename":"JS_ElmAttClass.png","filesize":50523,"height":528,"url":"https://i.ibb.co/1fhDbnY/JS-Elm-Att-Class.png","width":976}" data-trix-content-type="image/png" data-trix-attributes="{"presentation":"gallery"}" class="attachment attachment--preview attachment--png"><img src="https://i.ibb.co/1fhDbnY/JS-Elm-Att-Class.png" width="976" height="528"><figcaption class="attachment__caption"><span class="attachment__name">JS_ElmAttClass.png</span></figcaption></figure></div>