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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:38:16+00:00 2026-06-01T18:38:16+00:00

Here is some code: http://jsfiddle.net/T65E3/3/ I want to get an attr when i know

  • 0

Here is some code:
http://jsfiddle.net/T65E3/3/
I want to get an attr when i know class

$("#find").click(function() {
    $("#test").append($("#file").find("a.higlight").attr("rel"));
});

and html

 <div id="file">
<ul>
<li>
        <a class="higlight" rel="a">value_my</a>
        <a class="sth" rel="b">val</a>
        <a class="sth" rel="c">val2</a>
        <a class="sth" rel="d">val3</a>

</li>
</ul>
</div>

<button type="submit" id="find">find</button>
<div id="test"></div>
  • 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-06-01T18:38:17+00:00Added an answer on June 1, 2026 at 6:38 pm

    Your code as-is (if you include jQuery, your example had MooTools), works fine. There’s just one thing I’d like to point out.

    $("#file").find("a.higlight").attr("rel") // 'a'
    

    This will only return you the rel attribute of the first matched element. To get all the rel attributes (if there were multiple elements), you can use .map.

    $("#file").find("a.sth").attr("rel") // 'b'
    
    $("#file").find("a.sth").map(function(){
        return this.rel;
    }).get(); // ['b','c','d']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code here: http://jsfiddle.net/zkRq2/2/ that I am having issues with. If you
I have found some code on measuring execution time here http://www.dreamincode.net/forums/index.php?showtopic=24685 However, it does
I got some sample code from the net here: http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class That works fine. It
Here is the code: http://jsfiddle.net/ym2GQ/ p { background: lightblue; } .end { background: orange;
Please check this code: http://jsfiddle.net/rkumarnirmal/Rq7b2/2/ What I'm doing is I'm showing some text. If
Code example: http://jsfiddle.net/MhEPw/1/ I have two jQuery Deferred objects. I want to have more
I am trying to test some of these code here http://ha.ckers.org/xss.html on my code.
Here is some code I could not get to format properly in markdown, this
Here is some code: class Person def initialize(age) @age = age end def age
Even though the following works: http://jsfiddle.net/N7D5r/ My attempt at using the same code does

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.