I am using a jquery template to dynamically create multiple elements on the same page. Each item is as follows:
<div id ="DynamicValueAssignedHere"> <div class="something">Hello world</div> <div class="formdiv"> <form name="inpForm"> <input type="text" name="FirstName" /> <input type="submit" value="Submit" /> </form> </div> </div>
I would like to use jQuery to process the form on submit. I would also like to return the form values ββto their previous values ββif something goes wrong. My question is: How can I get the value of an input field using jQuery? For example, I can get the div value with the class "something" by doing
var something = $(#DynamicValueAssignedHere).children(".something").html();
Similarly, I want to get the value of a text field. Right now i tried
var text = $(#DynamicValueAssignedHere).children(".formdiv").findnext('input[name="FirstName"]').val();
but it doesn't seem to work
javascript jquery
user1625066 Jul 25 '12 at 16:32 2012-07-25 16:32
source share