Created
October 10, 2012 05:21
-
-
Save nakagak1/3863311 to your computer and use it in GitHub Desktop.
クリックしたら下線・取り消し線が出る Part2
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
<html> | |
<head> | |
<style> | |
.foo-before { | |
background-color: white; | |
color: black; | |
} | |
.foo-before p { | |
text-decoration: none; | |
} | |
.foo-before + div { | |
text-decoration: none; | |
} | |
.foo-after { | |
text-decoration: none; | |
} | |
.foo_after { | |
background-color: black; | |
color: white; | |
} | |
.foo-after p { | |
text-decoration: underline; | |
} | |
.foo-after + div { | |
text-decoration: line-through; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="foo" class="foo-before"> | |
<p>one</p> | |
<p>two</p> | |
<p>three</p> | |
<p>four</p> | |
</div> | |
<div> | |
This is sample text. | |
</div> | |
<script> | |
var foo = document.getElementById('foo'); | |
foo.onclick = function toggleStyle() { | |
this.classList.toggle('foo-after'); | |
this.classList.toggle('foo-before'); | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment