25219

Javascript if box checked

Question:

i have this form for adding videos. Now, there's a input field for "title" and i want that to disappear if you have pressed on the checkbox "tryout". How should i do that in JS.. i use jquery.

Answer1:

Assuming you have correct ids assigned for both fields something like this will work:

$('#tryout').click(function () { $('#title').toggle(!$(this).attr('checked')); });

Answer2:

you can just write inside document.ready function.

$("#chkboxId").clicked(function(){ if($(this).attr("checked")) $("#title").hide(); else $("#title").show(); });

Answer3:

<input type="checkbox" id="tryout" name="tryout" onclick="javascript:$('#tryout').hide();">Tryout</input>

Recommend

  • AngularJS ng-option get index
  • Migration of Google Project to Firebase Console
  • android 2.2 WebView and WebViewClient RTSP problem
  • GData Youtube : obtaining thumbnails
  • Save String as html file android
  • SQL Count. How can I count how many distinct values are in a table when an other two columns are mat
  • Does Julia have something equivalent to Ans (Matlab) or Last.value (R)
  • cannot be assigned to — it is read only - C#
  • Youtube upload API and cordova / phonegap
  • Modify a Google App Engine entity id?
  • Unable to hide youtube iframes in safari?
  • How can I see a list of all files that are different between two Hg repositories?
  • Receiver has no segue with identifier“***”
  • Using MouseListener to select a range of cells in a grid
  • Updating Dojo provide
  • How to explicitly/implicitly implemented interface members in C++/CLI?
  • Web.config system.webserver errors
  • How to assign byte[] as a pointer in C#
  • OOP Javascript - Is “get property” method necessary?
  • Cancel a live stream “fast motion” catch-up in Flash
  • How can I send an e-mail from a vbs script
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • req.body is undefined - nodejs
  • swift auto completion not working in Xcode6-Beta
  • Can Jackson SerializationFeature be overridden per field or class?
  • Modifying destination and filename of gulp-svg-sprite
  • Importing jscolor library in angular 2
  • jQuery tmpl and DataLink beta
  • Do create extension work in single-user mode in postgres?
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • R: gsub and capture
  • 0x202A in filename: Why?
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Comma separated Values
  • How to disable jQuery.jplayer autoplay?
  • CSS Applying specific rule for a specific monitor resolution with only CSS is posible?
  • how does django model after text[] in postgresql [duplicate]
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • File not found error Google Drive API
  • How to load view controller without button in storyboard?