{"id":389,"date":"2012-03-24T00:51:41","date_gmt":"2012-03-24T00:51:41","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=389"},"modified":"2012-03-24T00:51:41","modified_gmt":"2012-03-24T00:51:41","slug":"jquery-hide-show-textbox","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/jquery-hide-show-textbox\/","title":{"rendered":"jQuery Hide Show Textbox Examples"},"content":{"rendered":"<p>Many times it may have happened that you wanted to use jQuery to Hide\/Show text boxes when a checkbox is checked or a button is clicked. This article will show you how to use\u00a0<strong><em>jQuery to Show \/ Hide Textbox when checkbox is checked<\/em><\/strong>.<!--more--><\/p>\n<h2>How to\u00a0Hide \u00a0Or Show Textbox using jQuery &#8211; Examples<\/h2>\n<div class=\"make_demo\">\r\n\r\n\t<form action=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/themes\/ewd_blog_2017\/try_demo.php?post_id=389\" method=\"post\" name=\"form1\" target=\"_blank\" id=\"form1\">\r\n\r\n\r\n\t<input type=\"hidden\" name=\"shortcode_content\" id=\"shortcode_content\" value=\"\" \/>\r\n\r\n        <div class=\"try_demo_btn_container\">\r\n\r\n\r\n            <button type=\"submit\" name=\"sbt_make_demo\" id=\"sbt_make_demo\" class=\"btn-primary btn-try-demo\">\r\n                Try Demo\r\n            <\/button>\r\n\r\n\r\n        <\/div><!-- .try_demo_btn_container -->\r\n\r\n    <\/form>\r\n    <\/div>\r\n    \n<p>In order to see how to show textbox or hide textbox using jQuery when checkbox is checked, lets assume that we have a textbox and few checkboxes. So here it goes:<\/p>\n<h3>Example:\u00a0Show \/ Hide Textbox\u00a0when checkbox is checked using jQuery<\/h3>\n<pre class=\"lang:xhtml decode:true crayon-selected\">&lt;input type=\"checkbox\" class=\"hide\" \/&gt;&lt;input type=\"text\" value=\"Name\" \/&gt;&lt;br&gt;\n&lt;input type=\"checkbox\" class=\"hide\" \/&gt;&lt;input type=\"text\" value=\"Email\" \/&gt;&lt;br&gt;\n&lt;input type=\"checkbox\" class=\"hide\" checked=\"checked\" \/&gt;&lt;input type=\"text\" value=\"Address\" \/&gt;&lt;br&gt;\n\n&lt;script type=\"text\/javascript\"&gt;\n$(document).ready(function() {\n\n$('.hide').click(function() {\n$(this).next().toggle();\n});\n$('.hide:checked').next().hide();\n\n});\n&lt;\/script&gt;<\/pre>\n<p>This third input box is for the Address and it is hidden by default when the page loads. This is achieved by simply marking its &#8220;checked&#8221;\u00a0attribute\u00a0as &#8220;checked&#8221;. Just refer to the third input element&#8217;s HTML code to understand this. The corresponding jQuery code to achieve this is:<\/p>\n<pre class=\"lang:xhtml decode:true\">$('.hide:checked').next().hide();<\/pre>\n<p>Don&#8217;t forget to include your own version(preferably latest) of jQuery. Unless you have included a call to the jQuery framework, this demo will not work. Hope this helps.<\/p>\n<div class=\"make_demo\">\r\n\r\n\t<form action=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/themes\/ewd_blog_2017\/try_demo.php?post_id=389\" method=\"post\" name=\"form1\" target=\"_blank\" id=\"form1\">\r\n\r\n\r\n\t<input type=\"hidden\" name=\"shortcode_content\" id=\"shortcode_content\" value=\"\" \/>\r\n\r\n        <div class=\"try_demo_btn_container\">\r\n\r\n\r\n            <button type=\"submit\" name=\"sbt_make_demo\" id=\"sbt_make_demo\" class=\"btn-primary btn-try-demo\">\r\n                Try Demo\r\n            <\/button>\r\n\r\n\r\n        <\/div><!-- .try_demo_btn_container -->\r\n\r\n    <\/form>\r\n    <\/div>\r\n    \n<h5>Your turn!<\/h5>\n<p>Do you know of any other ways to use <strong>jQuery to Show \/ Hide textbox<\/strong>? Please feel free to share by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many times it may have happened that you wanted to use jQuery to Hide\/Show text boxes when a checkbox is checked or a button is clicked. This article will show you how to use\u00a0jQuery to Show \/ Hide Textbox when checkbox is checked.<\/p>\n","protected":false},"author":1,"featured_media":395,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[20,19,6,13],"tags":[43,41],"class_list":["post-389","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery-tips-and-tricks","category-jquery","category-snippets","category-tips-and-tricks","tag-jquery-snippets","tag-jquery-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-6h","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/389","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/comments?post=389"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/389\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/media?parent=389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}