Categories

.formInput()

Categories: Forms | Tree Traversal

.formInput()Returns: jQuery

Plugin: jQuery.fn.form

Description: Find all inputs of the first matched form of matched elements.

  • .formInput()

    version added: 1.0

The .formInput() method searchs for the first form element in matched elements and returns all inputs of this form.

  • Find form inputs.

    HTML:
    <div>
      <form id="form_1">
        <input type="text" name="A"/>
        <input type="text" name="B"/>
        <input type="text" name="C"/>
        <textarea type="text" name="D"></textarea>
      </form>
      <form id="form_2">
        <input type="text" name="X"/>
        <input type="text" name="Y"/>
        <input type="text" name="Z"/>
      </form>
    </div>
    Code:
    $('form').formInput();
    Results:
    <input type="text" name="A"/>
    <input type="text" name="B"/>
    <input type="text" name="C"/>
    <textarea type="text" name="D"></textarea>
  • Find form inputs.

    HTML:
    <div>
      <form id="form_1">
        <input type="text" name="A"/>
        <input type="text" name="B"/>
        <input type="text" name="C"/>
        <textarea type="text" name="D"></textarea>
      </form>
      <form id="form_2">
        <input type="text" name="X"/>
        <input type="text" name="Y"/>
        <input type="text" name="Z"/>
      </form>
    </div>
    Code:
    $('#form_2').formInput();
    Results:
    <input type="text" name="X"/>
    <input type="text" name="Y"/>
    <input type="text" name="Z"/>