JavaScript – Hide Paragraph

To hide a paragraph using JavaScript, get the reference to the paragraph element, and assign value of "none" to the property.


<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
    <p id="myPara">Hide Paragraph in JavaScript</p>
    <button type="button" onclick="changeStyle()">Click Me</button>
    function changeStyle(){
        var element = document.getElementById("myPara"); = "none";
Try Online


In this JavaScript Tutorial, we learned how to hide a paragraph using JavaScript.