Categories: PHP

How to show/hide an element on checkbox checked/unchecked states using jQuery?

Just use below code for following purpose

  1. How to show/hide an element on checkbox checked/unchecked states using jQuery?
  2. jquery show-hide div based on checkbox value
  3. If checkbox is checked show div
  4. on checkbox checked show div jquery
  5. How to show and hide input fields based on checkbox selection
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>How to show/hide an element on checkbox checked/unchecked states using jQuery?</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
 <script>

function myFunction() {
  var checkBox = document.getElementById("cwebsite");
 
  var text = document.getElementById("cwimg");
  
  if (checkBox.checked == true){
    text.style.display = "block";
  } else {
     text.style.display = "none";
  }
}

 </script>
</head>
<body>
    <form>
        <h3>Select your favorite sports:</h3>
        <input type="checkbox" value="1"  >
Basant

Recent Posts

AWS

Steps: AWS puttyubuntu sudo su apt update apt install apache2 service apache2 start service apache2…

3 days ago

How to Center submit button of wpForm

You must navigate to Settings ยป General first. Add wpf-center to the Form CSS Class…

8 months ago

How to add Marquee on any website wordpress,PHP,HTML,eBlogger ?

if you want to add marquee on any website (wordpress,PHP,HTML,Blogger). you just need to follow…

8 months ago

How to Autoplay and Loop YouTube Videos in WordPress

First Method: Use below code to play youtube video in loop and most important is…

1 year ago