O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting and Setting Hidden Form Attributes

var hiddenValue = $("#hidden").val(); var hiddenValue = $("#hidden").attr("other"); var hiddenValue = $("#hidden").prop("otherProp"); var hiddenValue = $("#hidden").data("storedValue");

A great HTML element to use if you need to supply additional information to the browser from a form is the hidden input. The hidden input is not displayed with the form, but it can contain a name and value pair that is submitted or even just values that you want to store in the form and have accessible during dynamic operations.

The parts to be sent with the form are the name and value attributes. However, you can attach additional values to a hidden form object or any HTML DOM object ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required