Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6347723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:16:33+00:00 2026-05-24T21:16:33+00:00

I would like to know the different elements and their types in a form.

  • 0

I would like to know the different elements and their types in a form.

My HTML looks like this:

<form action="save_form" method="post" id="newform" name="newform">
          <div class="form_description">
            <h2 class="editable">Form title. Click here to edit</h2>
            <p class="editable">This is your form description. Click here to edit.</p>
          </div>
          <ul id="form_body" class="ui-sortable">
          <li id="field1" class="">
            <a href="#" onclick="return false;" class="hover">
            <label class="editable" for="field1">Text1</label>
            <input type="text" name="field1" value="">
            </a>
            </li>
            <li id="field2" class="">
            <a href="#" onclick="return false;" class="hover">
            <label class="editable" for="field2">Paragraph2</label>
            <div><textarea cols="" rows="" class="textarea" name="field2"></textarea></div>
            </a>
            </li>
            <li id="radiogroup3" class="">
            <a href="#" onclick="return false;" class="hover">
            <label class="editable" for="radiogroup3">Label3</label>
            <input type="radio" id="radiogroup31" name="radiogroup3" value="1" class="element radio">
            <label class="choice editable" for="radiogroup31">option1</label>
            <input type="radio" id="radiogroup32" name="radiogroup3" value="2" class="element radio">
            <label class="choice editable" for="radiogroup32">option2</label>
            <input type="radio" id="radiogroup33" name="radiogroup3" value="3" class="element radio">
            <label class="choice editable" for="radiogroup33">option3</label>
            </a>
            </li></ul>
        </form>

I came up with the function below but this.type does not return any value (undefined) even though
firebug console shows the correct value.

I cannot use attr(‘type’) since it does not work for textarea and labels.

test = $('#newform').map(function(){ return $.makeArray(this.elements); });

if (test.length != 0) {
    test.each(function(){
        console.log($(this).type);
    });
}

Is there a way in which I can get all elements in a form, including label, textarea and radio buttons.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:16:35+00:00Added an answer on May 24, 2026 at 9:16 pm

    $(this).type is undefined, you should be using this.type to access the type property. You don’t really need to use map() either to get the elements. You can use this instead:

    var $test = $($newform.get(0).elements);
    

    But since elements won’t include labels you should just select the elements you want with a selector. Also since <label>‘s don’t have a type property you can access their nodeName instead which will be label.

    var $test= $('#newform').find('input,label,textarea');
    
    if ($test.length != 0) {
        $test.each(function(){
            var type = this.type ? this.type : this.nodeName.toLowerCase();
            console.log(type);
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know if I can open 2 different diagrams using MS
I would like to know which method should I choose when trying to create
I would like to know if its is possible to merge these elements with
I would like to know difference between static variables and global variables in terms
I would like to know the difference and additional features in Antennahouse over Apache
I would like to know what the difference between these instructions is: MOV AX,
I would like to know what is the difference between initializing a static member
I would like to know if there is a difference in speed between computing
Just I would like to know, is there any difference between if (a==5) or
i would like know some reference. I know i can googling it. but prefer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.