div content change on button click? JS/JQ/HTML
Go to solution
Solved by FJLJ,
NVM wont be needed I see the problem..
with JQuery you will need to put your script
<script type="text/javascript"> $('#btnClick').on('click',function(){ if($('.add_student').css('display')!='none'){ $('.del_student').show(); $('.add_student').hide(); }else if($('.del_student').css('display')!='none'){ $('.add_student').show(); $('.del_student').hide(); } }); </script>
at the bottom of the page... just before the </body> tag
<html> <head> <meta charset="utf-8"> <title> add/delete </title> <!-- css file for the page linked below. --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="checkpoint.css"> </head> <body> <div class="container"> <div class="header"> <!-- navigation to load the other pages below --> <a href="marking.html" class="nc">Marking</a> <a href="#" class="currentpage">Staff</a> <a href="students.html" class = "nc">Students</a> <a href="" class="nclogin"> Log In</a> </div> <!-- header div ends here --> <div class="content"> <div class="card"> <h1>Add/Delete Student</h1> </div> <button id="btnClick" class="switchBtn">Toggle</button> <div class="results2"> <div class="add_student"> <form action="/action_page.php"> <h1>Add Student</h1> <label>Student ID : </label> <input type="text" name="studentnum" required><br> <label>First name : </label><input type="text" name="firstname" required><br> <label>Last name : </label> <input type="text" name="lastname" required><br> <input type="submit" class="switchBtn2" value="Submit"> </form> </div> <div class="del_student"> <h1>Delete Student</h1> <!-- inputs to search will go here --> </div> </div> <!-- add a selector to choose whether you delete or add. --> </div> <!--content div ends here --> <div class="footer"> </div> <!-- footer ends here --> </div> <!-- container div ends here --> <!-- script to switch the content shown from add to delete --> <script type="text/javascript"> $('#btnClick').on('click',function(){ if($('.add_student').css('display')!='none'){ $('.del_student').show(); $('.add_student').hide(); }else if($('.del_student').css('display')!='none'){ $('.add_student').show(); $('.del_student').hide(); } }); </script> </body> </html>
cheers
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now