Read More Read Less Button from javascript without loading
Read More Read Less Button from javascript without loading
Learn how to create a "read more - read less" button with JavaScript.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#see_more {display: none;}
</style>
</head>
<body>
<h2>Read More Read Less Button with javascript</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy <span id="dot">.....</span><span id="see_more">text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum</span></p>
<button onclick="SeeMore()" id="Button">Read more</button>
<script>
function SeeMore() {
var dot = document.getElementById("dot");
var moreText = document.getElementById("see_more");
var btnText = document.getElementById("Button");
if (dot.style.display === "none") {
dot.style.display = "inline";
btnText.innerHTML = "Read more";
moreText.style.display = "none";
} else {
dot.style.display = "none";
btnText.innerHTML = "Read less";
moreText.style.display = "inline";
}
}
</script>
</body>
</html>
Comments (0)
Facebook Comments (0)