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

The Archive Base Latest Questions

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

I need to fetch one of json encoded data inside data-people: <ul> <li data-test=one

  • 0

I need to fetch one of json encoded data inside data-people:

<ul>
  <li data-test="one" data-people='{"name" : "Paul", "color" : "black"}'>Paul</li>
  <li data-test="two" data-people='{"name" : "John", "color" : "blond"}'>John</li>
  <li data-test="three" data-people='{"name" : "Jane", "color" : "black"}'>Jane</li>
</ul>

It is pretty straight forward to fetch via data-test (just example):

$('ul li[data-test="two"]').show();

Now I want to show ul li with data-people that has color blond (ignoring data-test that only exist for sample above).

I tested below but this doesn’t work as expected:

$('ul li[data-people="{"color": "blond"}"]').show();

I don’t mean to get color value like: $('ul li').data('people').color, but to do proper CSS syntax inside the object.

Any hint is very much appreciated. Thanks.

  • 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-16T18:38:30+00:00Added an answer on June 16, 2026 at 6:38 pm

    You can’t do this in any clean way using just selectors except by using the *= (“attribute contains”) selector. And that one will only work if the JSON contains exactly that substring – remove the space before : and it will stop working.

    $('ul li[data-people*=\'"color" : "blond"\']').show();
    

    What you probably really want is .filter():

    $('ul li[data-people]').filter(function() {
        return $(this).data('people').color == 'blond';
    }).show();
    

    This way you use the (fast) CSS selector engine to get only relevant elements (those that have a data-people attribute) and then filter the resultset using the callback function.

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

Sidebar

Related Questions

Im using vb.net and I need to fetch data from two different tables and
I'm trying to fetch some data using only one query. I need to fetch
I have one table TABLE_QUESTION. I need to fetch record by passing exam_id and
I need to fetch data from normalized MSSQL db and feed them in Solr
Can any one please let me know, that, i need to fetch last 4
I need to fetch 2 million records from the oracle database(1 year data). When
There is a json(#json) like as follow, in student section, first two one is
Two functions need to execute in Javascript, and one should start when another has
i have two tables: products products_images -id -id -name -product_id -image_name There is one
i need to fetch a url with javascript/jquery and not php. i've read that

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.