Skip to content

Instantly share code, notes, and snippets.

@tylerzey
Created March 16, 2018 21:33
Show Gist options
  • Save tylerzey/df6a9ce0547e58da0db2a46f83e57f72 to your computer and use it in GitHub Desktop.
Save tylerzey/df6a9ce0547e58da0db2a46f83e57f72 to your computer and use it in GitHub Desktop.
adding / removing class with js for s
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div class="class tyler">This has class tyler</div>
<div class="class sophia">This shas class Sophia</div>
<script type="text/javascript">
'use strict';
let tyler = document.querySelector('.tyler');
let sophia = document.querySelector('.sophia');
tyler.classList.remove('class');
sophia.classList.add('newclass');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment