Skip to content

Instantly share code, notes, and snippets.

@nakagak1
Created October 10, 2012 05:21
Show Gist options
  • Save nakagak1/3863311 to your computer and use it in GitHub Desktop.
Save nakagak1/3863311 to your computer and use it in GitHub Desktop.
クリックしたら下線・取り消し線が出る Part2
<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