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 :: functions javascript 
Javascript :: react native smart splash screen 
Javascript :: printing in javascript 
Javascript :: setimmediate node example 
Javascript :: date pipe 
Javascript :: values javascript 
Javascript :: react native scrollview item bottom 
Javascript :: usesearchparams react router 
Javascript :: javascript sort array of objects by key value ascending and descending order 
Javascript :: interface in javascript 
Javascript :: javascript remove the last element from array 
Javascript :: javascript make do while loop 
Javascript :: function in javascript 
Javascript :: how to map over arrays vuejs 
Javascript :: javascript quiz questions and answers 
Javascript :: splice state react 
Javascript :: custom js shopify 
Javascript :: Adding an item to an array 
Javascript :: is there an api for netflix shows 
Javascript :: calculate days between two dates in javascript 
Javascript :: set active element javascript 
Javascript :: how to break from map in javascript 
Javascript :: how does an if statement work 
Javascript :: how to wait for the subscribe to finish before going back to caller method in angular 
Javascript :: javascript free code editors 
Javascript :: js number format space 
Javascript :: javascript string problems 
Javascript :: recorrer array javascript 
Javascript :: display form input on console jquery 
Python :: python int64index 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =