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 7428633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:50:00+00:00 2026-05-29T08:50:00+00:00

I have an array with different elements inside it. Like array contain input elements

  • 0

I have an array with different elements inside it. Like array contain input elements and select elements. I want to check for particular type. I tried this but it didn’t work

var mandotaryElementsArray = $('.mandotary');

$.each(mandotaryElementsArray, function(index, element){

    if (element == input) {

        var $inputElement = $(this);
        var test1;

    } else if (element == select) {

        var $selectElement = $(this);
        var test2;

    }

}); //end of .each()

Actually i want to check something that is similar to instance of in Java. Here i want to check if element is type of input then do this, if element is type of select then do this, if element is type of radiobutton then do this.. How can i make this check here?
Thanks

  • 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-29T08:50:01+00:00Added an answer on May 29, 2026 at 8:50 am

    You can use either the .tagName property (which always returns uppercase for HTML):

    $('.mandotary').each(function(index, element) {
        if (element.tagName == "INPUT") {
            // code here
        } else if (element.tagName == "SELECT") {
            // code here
        }
    });
    

    Or, you can use jQuery’s .is():

    $('.mandotary').each(function(index, element) {
        var $element = $(element);
        if ($element.is('input')) {
            // code here
        } else if ($element.is('select')) {
            // code here
        }
    });
    

    Even better would probably be to let the selector do all the work for you and just select the items you want for a particular operation and operate on the desired selector like this:

    $('input.mandotary').hide();
    $('select.mandotary').show();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a structure of html like this: <div id="triger1">some elements inside</div> <div id="triger2">some
I have an array of different type objects and I use a BinaryWriter to
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
An array is defined of assumed elements like I have array like String[] strArray
I have a form with some different input elements. One of these is a
I have an array of different elements stored from a previous selection, call it
I have an array char[] Select = {'A','B','C','D','E','F','G','H','I','J'} and each element in this array
I have two arrays containing the same elements, but in different orders, and I
I have a 4D array of measurements in MATLAB. Each dimension represents a different
I have a base class object array into which I have typecasted many different

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.