WebJul 2, 2010 · get all the inputs type: allInputs.attr ('type'); get the values: allInputs.val (); NOTE: .val () is NOT the same as :checked for those types where that is relevent. use: .attr ("checked"); EDIT Feb 1, 2013 - re: jQuery 1.9 use prop () not attr () as attr will not return proper values for properties that have changed. .prop ('checked'); or simply WebMay 3, 2011 · Both select fields have a ‘name’ attribute, so we can find and select them with jQuery. The logic of the functions we’ll build is pretty simple: IF the ‘Sales’ option is selected, then add ‘some names’ to the second select input, and the same goes for the other departments. So let’s get right on it!
.val() jQuery API Documentation
WebJan 15, 2016 · I tried the following: $ ('#ins').html ($ (this).attr ('name').val ()); #ins is the div, where I am writing the events such as a click was made on the input with name = name. This way I want to create a plugin which would guide me to get to know which fields are getting some events. jquery html input Share Improve this question Follow WebDec 8, 2010 · $ ("#form2 input").val ('Hello World!'); Or, $ ("#form2 input [name=name]").val ('Hello World!'); If you're stuck with an invalid page and want to select all #name s, you can use the attribute selector on the id: $ ("input [id=name]").val ('Hello World!'); Share Improve this answer Follow answered Dec 8, 2010 at 12:21 Kobi 134k 41 256 289 building a community center
.val() jQuery API Documentation
WebFind the value of an input box. Demo: .val ( value ) Returns: jQuery Description: Set the value of each element in the set of matched elements. version added: 1.0 .val ( value ) value Type: String or Number or Array A string of text, a number, or an array of strings corresponding to the value of each matched element to set as selected/checked. Webbut the "input" is desired so it only gets the inputs and does not use the universal '*" when the form of $(':radio') is used which equates to $('*:radio'); EDIT Aug 19, 2015: preference for the $('input[type=radio]'); should be used as that then allows modern browsers to optimize the search for a radio input. WebOnce you've got the class in there, you can reference it with a dot instead of the hash, like so: var value = $ ('#a .b').val (); or var value = $ ('#a input.b').val (); which will limit it to 'b' class elements that are inputs within the form (which seems to be close to what you're asking for). Share Improve this answer Follow crowder tour dates 2017