Title: javascript within widget form
Last modified: August 19, 2016

---

# javascript within widget form

 *  [Koff](https://wordpress.org/support/users/orenkolker/)
 * (@orenkolker)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/javascript-within-widget-form/)
 * Hi,
    I am trying to add a widget. The widgets form should be dynamic. for example
   Email filed is shown just if a checkbox is selected.
 * From some reason i cant get it to work.
 * Here is the code:
 *     ```
       <input id="checkme" type="checkbox" />
       <div id="extra">
       <label for="email">Email Address:</label>
       <input id="email" type="text" />
       </div>
       ```
   
 * and the javascipt:
 *     ```
       <script type="text/javascript"> 
   
       	$(document).ready(function(){
       		//Hide div w/id extra
       	   $("#extra").css("display","none");
       		// Add onclick handler to checkbox w/id checkme
       	   $("#checkme").click(function(){
       		// If checked
       		if ($("#checkme").is(":checked"))
       		{
       			//show the hidden div
       			$("#extra").show("fast");
       		}
       		else
       		{
       			//otherwise, hide it
       			$("#extra").hide("fast");
       		}
       	  });
   
       		});
       	 </script>
       ```
   

The topic ‘javascript within widget form’ is closed to new replies.

## Tags

 * [javasctipt](https://wordpress.org/support/topic-tag/javasctipt/)
 * [widget](https://wordpress.org/support/topic-tag/widget/)

 * 0 replies
 * 1 participant
 * Last reply from: [Koff](https://wordpress.org/support/users/orenkolker/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/javascript-within-widget-form/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
