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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:20:41+00:00 2026-05-27T08:20:41+00:00

<body> <span someAttribute=xyz>…..</span> … <div> … <span someAttribute=abc>…..</span> … <div someAttribute=pqr>…..</div> … </div> </body>

  • 0
<body>
  <span someAttribute="xyz">.....</span>
  ...
  <div>
    ...
    <span someAttribute="abc">.....</span>
    ...
    <div someAttribute="pqr">.....</div>
    ...
  </div>
</body>

Here is a sample html page.. I need to select the html elements by its attributes i can get the attribute values by getAttribute() but i need to select all the elements first.

How in javascript to get elements which has the attribute name as “someAttribute”. Once i get the elements i can get the attribute values and use my function.

Note: i want to do this without using jquery.

  • 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-27T08:20:42+00:00Added an answer on May 27, 2026 at 8:20 am

    store each element in a array the loop throught each element, and if the element contains the attribute someAttribute do somgthing.

    var arr_elms = [];
    arr_elms = document.body.getElementsByTagName("*");
    var elms_len = arr_elms.length;
    
    for (var i = 0; i < elms_len; i++) {
      if(arr_elms[i].getAttribute("someAttribute") != null){  
       alert("FOUND : " + arr_elms[i].getAttribute("someAttribute"));
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say i have the following web page: <html> <body> <div class="transform"> <span>1</span> </div>
Given the following XML structure <html> <body> <div> <span>Test: Text2</span> </div> <div> <span>Test: Text3</span>
The code is as below: <html> <head> <title>test</title> </head> <body> <div><span>shanghai</span><span class=margin> </span><span>male</span></div> </body>
Are html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p,
I have just normalized the font size with this: html, body, div, span, applet,
Given the following HTML: <!doctype html> <html> <body> <span style=background-color: blue;> Some text here
click(new XPath(/HTML[1]/BODY[1]/DIV[1]/DIV[2]/DIV[1]/DIV[2]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/SPAN[1]/SPAN[2]/#text[1])); ..or var foo = document.evaluate(/HTML[1]/BODY[1]/DIV[1]/DIV[2]/DIV[1]/DIV[2]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/SPAN[1]/SPAN[2]/#text[1], document, null, XPathResult.ANY_TYPE,null); Result to: [Exception... The
I have the following CSS: html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td { background: transparent; border: 0; font-size: 100%; margin:
I have this html code: <body> <div class=CodeRay> <div class=code><pre><span class=no> 1</span> require <span
say i have html/body/span/div/p/h1/i/font html/body/span/div/div/div/div/table/tr/p/h1 html/body/span/p/h1/b html/body/span/div how can i get the common ancestor?

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.