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

  • Home
  • SEARCH
  • 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 6643585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:04:03+00:00 2026-05-26T00:04:03+00:00

There are methods available in JavaScript to get HTML elements using their ID, Class

  • 0

There are methods available in JavaScript to get HTML elements using their ID, Class and Tag.

document.getElementByID(*id*);
document.getElementsByClassName(*class*);
document.getElementsByTagName(*tag*);

Is there any method available to get the elements according to the attribute name.

EX:

<span property="v:name">Basil Grilled Tomatoes and Onions</span>

Like:

document.getElementsByAttributeName("property");
  • 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-26T00:04:04+00:00Added an answer on May 26, 2026 at 12:04 am

    Yes, the function is querySelectorAll (or querySelector for a single element), which allows you to use CSS selectors to find elements.

    document.querySelectorAll('[property]'); // All with attribute named "property"
    document.querySelectorAll('[property="value"]'); // All with "property" set to "value" exactly.
    

    (Complete list of attribute selectors on MDN.)

    This finds all elements with the attribute property. It would be better to specify a tag name if possible:

    document.querySelectorAll('span[property]');
    

    You can work around this if necessary by looping through all the elements on the page to see whether they have the attribute set:

    var withProperty = [],
        els = document.getElementsByTagName('span'), // or '*' for all types of element
        i = 0;
    
    for (i = 0; i < els.length; i++) {
        if (els[i].hasAttribute('property')) {
            withProperty.push(els[i]);
        }
    }
    

    Libraries such as jQuery handle this for you; it’s probably a good idea to let them do the heavy lifting.

    For anyone dealing with ancient browsers, note that querySelectorAll was introduced to Internet Explorer in v8 (2009) and fully supported in IE9. All modern browsers support it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, I know there are methods off of the generic List<> class already in
Are there any known methods of finding peers without using a dedicated central server?
There are several different methods for converting floating point numbers to Integers in JavaScript.
What methods are available to monitor the status of IFRAME page, I know there
Creating a document fragment using plain Javascript is dead simple: var docFragment = document.createDocumentFragment();
I've decided to get used to using Javascript as my server sided (I'm using
the website in the main document includes a javascript file using the following statement:
Is there a method available for copying a section out of a shape to
Is there a convenience method available in the java standard libraries to check whether
There are methods to transfer a CGPoint from one UIView to another and from

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.