jQuery: Hide all the input elements within a form
jQuery core : Exercise-3 with Solution
Hide all the input elements within a form.
Test Data :
<body> <form name='demo_form'> First name: <input type="text" name="fname"><br> Last name: <input type="text" name="lname"><br> <input type="submit" value="Submit"> </form> </body>
Solution:
HTML Code :
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<meta charset="utf-8">
<title>Hide all the input elements within a form</title>
</head>
<body>
<form name='demo_form'>
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
JavaScript Code :
$( demo_form.elements ).hide();
Live Demo:
See the Pen jquery-core-exercise-3 by w3resource (@w3resource) on CodePen.
Contribute your code and comments through Disqus.
Previous: Set the background color of a page to red.
Next: Find the specific option tag text value of a selected option.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework