Skip to content

Instantly share code, notes, and snippets.

@saiyerniakhil
Created June 6, 2019 11:21
Show Gist options
  • Save saiyerniakhil/4a9811daf62efb2c64e389c4f164254e to your computer and use it in GitHub Desktop.
Save saiyerniakhil/4a9811daf62efb2c64e389c4f164254e to your computer and use it in GitHub Desktop.
<!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>Sample</title>
<style>
div#div-1 {
border: 1px solid black;
width: 200px;
height: 100px;
}
div#div-2 {
border: 1px solid black;
width: 200px;
height: 100px;
}
</style>
</head>
<body>
<div id="div-1">
Hello
</div>
<br>
<div id="div-2">
Hello Again!
</div>
<br>
<button id="changer">
change!
</button>
<script>
ele = document.getElementById('changer')
ele.addEventListener("click",function() {
temp = document.querySelector("#div-2").innerHTML
document.querySelector("#div-2").innerHTML = document.querySelector("#div-1").innerHTML
document.querySelector("#div-1").innerHTML = temp
},false)
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment