Skip to content

Instantly share code, notes, and snippets.

@theredstapler
Created June 17, 2016 15:32
Show Gist options
  • Select an option

  • Save theredstapler/c5991d5b09a76b68a808fd0f84f402c0 to your computer and use it in GitHub Desktop.

Select an option

Save theredstapler/c5991d5b09a76b68a808fd0f84f402c0 to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="jquery.min.js"></script>
<link rel="stylesheet" href="styles/default.css">
<script src="highlight.pack.js"></script>
</head>
<body>
<pre><code class="javascript">var test;
alert(1+1);</code></pre>
<input id="b" type="button" value="highlight!" />
<script>
$('#b').click(function(){
$('code').removeClass('javascript');
$('code').addClass('C');
hljs.highlightBlock($('code').get(0));
});
</script>
</body>
</html>
@CodingVlogsWeb
Copy link

How to change code theme with a button click using highlight.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment