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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:36:07+00:00 2026-06-03T08:36:07+00:00

Is it possible to select multiple elements using an array selector ? If so,

  • 0

Is it possible to select multiple elements using an array selector?

If so, what is the best way to do it? In my project, I need to use only array selectors.

This is my sample code:

<ul>
    <li>1<li>
    <li>2<li>
    <li>3<li>
    <li>4<li>
    <li>5<li>
</ul>
<a href="#">select</a>​

$('a').click(function(){
    var element = $('ul').find('li')[0]; // Instead is it possible $('ul').find('li')[0,3,4]? I know we can select finding each alone. But is there any shortcut?
    $(element).css({border:'1px solid red'});
})​
  • 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-03T08:36:08+00:00Added an answer on June 3, 2026 at 8:36 am

    This would give desired result. Simply filter by index() and use inArray().

    var arr = [0, 3, 5];
    $('ul li').each(function() {
        if ($.inArray($(this).index(), arr) < 0)
            return;
        // Code here!
        $(this).css('border', '1px solid red');
    });
    

    Basicly all the <li> are run through the each() and then I loop to check if given .index() is in given array. If they don’t exist ( $.inArray() == -1 ) then I do a return; to skip execution.

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

Sidebar

Related Questions

I'm wondering if it's possible to use a wildcard to select multiple cookies. I'm
Is it possible to select multiple files using java.awt.FileDialog? Because I want my dialog
Is there a way to select multiple accounts to share to using http://getsharekit.com ?
Is it possible to select multiple gridview rows using Ctrl +Click and then delete
is it possible to be able Multiple select files when make browse file? any
Is it possible to select DISTINCT values using Rails3 JQuery autocomplete gem?
I need to select elements based on values stored in an element's .data() object.
Possible Duplicate: SQL - how to SELECT multiple tables and JOIN multiple rows from
Is there a way to select multiple values with prepared statements in (My-)SQL? I'm
I have a selection box that allows you to select multiple options. I need

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.