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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:41:05+00:00 2026-06-02T21:41:05+00:00

Ok, so I have this div which contains a ul: <html> <head> <script type=text/javascript

  • 0

Ok, so I have this div which contains a ul:

    <html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" ></script>
<script type="text/javascript">
$(document).ready(function(){
  $("button").click(function(){
    alert($('#slider ul li[display="none"]:first').text());
  });
});
</script>
<style type="text/css">
li
{
display:inline;
margin: 20px;
}
</style>
</head>
<body>
<div id="slider" style="width:100%; overflow-x:hidden"><ul><li style="display:none">Steve 1</li><li style="display:none">Frank</li><li>Tim</li><li>Steve</li><li>Frank</li><li>Tim</li><li>Steve</li><li>Frank</li><li>Tim</li><li>Steve</li><li>Frank</li><li>Tim</li><li>Steve</li><li>Frank</li><li>Tim</li><li>Steve</li><li>Frank</li><li>Tim</li><ul>
</div>
<button type="button" style="float:left">Previous</button><div style="float:right">Next</div>
</body>
</html>

What I wanted to happen is that when you press the Previous button it would find the first item in the list with display none and show a message with it’s content. In this case Steve1.

So I used $('#slider ul li[display="none"]:first') which means it should find the div named slider and it’s first list item in the ul with display:none.

I get a blank back in the message.

Anyone know what I’m doing wrong.

I think it’s got to do with the attribute part which I constructed from:

http://api.jquery.com/attribute-equals-selector/

  • 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-02T21:41:06+00:00Added an answer on June 2, 2026 at 9:41 pm
    $('#slider ul li[style="display:none"]:first')
    

    Square brackets select elements based on attributes. There was no display attribute. But the style attribute can be used. If the style attribute has other styles than just display:none then you can use a RegExp selector:

    $('#slider ul li[style*="display:none"]:first')
    

    The asterik (*) means that the string can exist anywhere inside the actual value of the attribute.

    Here is a demo: http://jsfiddle.net/TAv3d/

    Docs for jQuery selectors: http://api.jquery.com/category/selectors/

    Alternatively you can use functions for DOM traversal (and it’s a bit faster):

    $('#slider').children('ul').children('li').filter('[style="display:none"]').first();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have script like this <html xmlns=http://www.w3.org/1999/xhtml> <head> <meta http-equiv=Content-Type content=text/html; charset=UTF-8 /> <title>Testing
Ok, I have a label, inside this label is a div, which contains an
I have this code which can display drop down in div tag of html.
I have this jquery script which suppose to hide/show div element base on the
I have a div which has some text, but according to different situations this
I have this HTML code which simulates a dropdown multi-checkbox <div> <div class=select> <span>Select
When I have this, the div, which just has text in it, uses all
I have this fragment that demonstrates the problem: <html> <head> <title>height query demo</title> <script
I have a simple html, a div which contains some html and a delete
I have a div which is defined via a this. Imagine it is the

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.