Last active
January 10, 2018 08:10
-
-
Save qqpann/f13d4e299fb98cece0e3638d9e9a65ac to your computer and use it in GitHub Desktop.
CSS JS | change class button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button onclick="book()">図書</button> | |
<button onclick="mgzn()">雑誌</button> | |
<h2>図書</h2> | |
<div id="book" class="red-card"> | |
<p> | |
Book book book. | |
</p> | |
</div> | |
<script src="switch-class.js" type="text/javascript"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function chClassName(idnm, classnm) { | |
document.getElementById(idnm).className = classnm; | |
} | |
function book() { | |
chClassName('book', 'red-card'); | |
chClassName('mgzn', 'red-card-disabled'); | |
} | |
function mgzn() { | |
chClassName('book', 'red-card-disabled'); | |
chClassName('mgzn', 'red-card'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment