$('<input>').attr('type','hidden').appendTo('form');
To answer your second question:
$('<input>').attr({
type: 'hidden',
id: 'foo',
name: 'bar'
}).appendTo('form');
More Related Contents:
- jQuery AJAX submit form
- Prevent double submission of forms in jQuery
- How can I get form data with JavaScript/jQuery?
- How to reset a form using jQuery with .reset() method
- jquery disable form submit on enter
- How to submit an HTML form without redirection
- Drop-down box dependent on the option selected in another drop-down box
- How to hide form code from view code/inspect element browser?
- How to prevent page from reloading after form submit – JQuery
- jquery validate plugin on dynamic form inputs not working
- Property ‘submit’ of object # is not a function
- Adding rows dynamically with jQuery
- Best JavaScript solution for client-side form validation and interaction? [closed]
- How to ajax-submit a form textarea input from CKEditor?
- Change the content of a div based on selection from dropdown menu
- jQuery Change event on an element – any way to retain previous value?
- Detect which form input has focus using JavaScript or jQuery
- What is the meaning of onsubmit=”return false”? (JavaScript, jQuery)
- Trigger standard HTML5 validation (form) without using submit button?
- jQuery: checking if the value of a field is null (empty)
- How can I get all a form’s values that would be submitted without submitting [duplicate]
- Trigger standard HTML validation (form) without using submit button? [duplicate]
- jQuery see if any or no checkboxes are selected
- Get content of span
- Is there an “after submit” jQuery option?
- Is there a better jQuery solution to this.form.submit();?
- jQuery asynchronous function call, no AJAX request
- Form Validation With Bootstrap (jQuery)
- .js.erb VS .js
- jquery serialize and multi select dropdown