Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Hide div js

// Hide div :
document.getElementById(div_id).style.display = none;

/// Show div :
document.getElementById(div_id).style.display = block;
Comment

javascript hide and show

//Hide
document.getElementById("id").style.display = "none";
//Show
document.getElementById("id").style.display = "block";
Comment

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
Comment

Html show and hide div


METHOD 1
=================
function myFunction() {
  var x = document.getElementById("myDIV");
  if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display = "none";
  }
}




METHOD 2
=================


<!--SELECT ELEMENT-->
<div class="form-group row">
    <label class="col-md-3 label-control" for="projectinput1"> <b>Group Type</b></label>
    <div class="col-md-4 mx-left">
        <select id="projectinput7" name="period1" class="form-control round" required="" onchange="select_group(this.value)">
            <option value="" selected="">- Select Group Type -</option>
            <option value="GROUP-SAVINGS">Cooperative Group Savings</option>
            <option value="GROUP-LOANS">Cooperative Group Loans</option>
        </select>
    </div>
</div>



<style>
    .showx{
        visibility: visible;
        display: block;
    }
    .hidex{
        visibility: hidden;
        display: none;
    }
</style>



<script>

    function select_group(group_type){

        var group_type;

        //alert(group_type);

        //GROUP SAVINGS
        if(group_type == 'GROUP-SAVINGS')
        {
            //show
            document.getElementById("payment_period").style.visibility = "visible";
            document.getElementById("payment_period").setAttribute("style", "showx");

            //hide
            document.getElementById("tenor").style.display = "none";
            document.getElementById("optional_info").style.display = "none";
        }

        //GROUP LOANS 
        if(group_type == 'GROUP-LOANS')
        {
            //show
            document.getElementById("payment_period").style.display = "none";
            document.getElementById("amount_payable").style.display = "none";
            document.getElementById("optional_info").setAttribute("style", "hidex");
            
            //hide
            document.getElementById("tenor").setAttribute("style", "showx");
            document.getElementById("optional_info").setAttribute("style", "showx");
        }
    }

</script>
Comment

hide or show element in javascript

<td class="post">

<a href="#" onclick="showStuff('answer1', 'text1', this); return false;">Edit</a>
<span id="answer1" style="display: none;">
<textarea rows="10" cols="115"></textarea>
</span>

<span id="text1">Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum</span>
</td>
<script>
  
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';
}
</script>
Comment

show hide div in javascript

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
  </head>

  <body>
    <div id="box" style="background-color: salmon; width: 100px; height: 100px">
      Box 1
    </div>

    <button id="btn">Hide div</button>

    <script src="index.js"></script>
  </body>
</html>
Comment

hide and show div using javascript with example

hide and show divs using javascript
Comment

PREVIOUS NEXT
Code Example
Javascript :: Simple Mustache.js 
Javascript :: Variables In Self Invoking Function 
Javascript :: Clear for me API jquery 
Javascript :: bcrypt npm 
Javascript :: Modules: Remember All Strings Will Now Have a Property After You Use Require 
Javascript :: online convert javascript to typescript 
Javascript :: javascript get next month name 
Javascript :: phaser reverse matrix rows 
Javascript :: controllare che ci sia un file in javascript 
Javascript :: vimscript replace function 
Javascript :: Create Nodejs logger that does not replace file when app/server restarts 
Javascript :: replace text content with element node 
Javascript :: change button text dynamically angular 6 
Javascript :: show hide element with javascript stack overflow 
Javascript :: how to display unicode in javascript 
Javascript :: Function Written In Constructor Involving A Promise, Can Be Accessed As Below 
Javascript :: Using an object of functions as a parameter into a function 
Javascript :: app-shell 
Javascript :: create object in jquery dynamically 
Javascript :: express dynamic api template 
Javascript :: expact 
Javascript :: supabase 
Javascript :: React Gotchas 
Javascript :: radio button remove checked 
Javascript :: insert element in array javascript 
Javascript :: button click event 
Javascript :: js return 
Javascript :: js duplicate 
Javascript :: js pow function 
Javascript :: oridnal suffix 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =