Skip to content

Instantly share code, notes, and snippets.

@VorontsovIE
Created October 26, 2020 11:17
Show Gist options
  • Save VorontsovIE/b0e918c0c30dac435577ae257e5b052d to your computer and use it in GitHub Desktop.
Save VorontsovIE/b0e918c0c30dac435577ae257e5b052d to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
<title>{%block title%}{%endblock%}</title>
<style type="text/css">
li {
color: black;
background-color: white;
}
li.highlighted {
color: red;
background-color: black;
}
</style>
<!-- ... -->
</head>
<body>
<div class="container">
<ul class="menu">
<li>Item</li>
<li>Item 2</li>
</ul>
{% block content %} Default {% endblock %}
<button onClick="markup()">Toggle</button>
</div>
<script>
$(function(event) {
let highlighted = false;
function markup() {
console.log('markup');
if (highlighted) {
$('li').removeClass('highlighted');
highlighted = false;
} else {
$('li').addClass('highlighted');
highlighted = true;
}
}
$('li').click(function(event){
let text = event.target.textContent;
alert(text);
// console.log(event);
});
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment