Show/hide text input via Checkbox
Description
The following code shows how to show/hide text input via Checkbox.
Example
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-1.6.4.js'></script>
<link rel="stylesheet" type="text/css"
href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css">
<script type='text/javascript'
src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type='text/javascript'
src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
<style type='text/css'>
#textContainer {<!--from ww w .j a va2s . c o m-->
margin-bottom: 20px;
}
#container {
width: 200px;
}
</style>
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$(function () {
$('#checkbox1').change(function () {
$('#textContainer').toggle(!this.checked);
alert("Hide Textbox? " + this.checked);
}).change();
});
});//]]>
</script>
</head>
<body>
<div id="container">
<div id="textContainer">
<label id="lblPostalCode">Type text here:</label>
<input type="text" />
</div>
<input type="checkbox" id="checkbox1" />
<label id="lblRegionCheckBox" for="checkbox1">Hide Textbox</label>
</div>
</body>
</html>