hide() javascript code example

Example 1: js hide div

//If you have jquery, you can use the following method:
$("#mydiv").hide(); //hides div.
$("#mydiv").show(); //shows div.
//If you don't have jquery...
//search up the following: html how to add jquery

Example 2: hide element js

function showStuff(id, text, btn) {
    document.getElementById(id).style.display = 'block';
    // hide the lorem ipsum text
    document.getElementById(text).style.display = 'none';
    // hide the link
    btn.style.display = 'none';
}

Example 3: javascript hide a div

Hide/show this div

('#main').hide(); //to hide // 2nd way, by injecting css using jquery $("#main").css("display", "none");

Example 4: js hide element

Check this! https://dev.to/devlorenzo/js-hide-and-show-32og

Tags:

Misc Example