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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:23:39+00:00 2026-05-23T07:23:39+00:00

Given variable ${text} , which represents a large block of text such as …

  • 0

Given variable ${text}, which represents a large block of text such as …

…

With an area of almost 1,800,000
square kilometres (700,000 sq mi),
Libya is the fourth largest country in
Africa by area, and the 17th largest
in the world.[9] The capital, Tripoli,
is home to 1.7 million of Libya’s 6.4
million people. The three traditional
parts of the country are Tripolitania,
Fezzan, and Cyrenaica. Libya has the
highest HDI in Africa and the fourth
highest GDP (PPP) per capita in Africa
as of 2009, behind Seychelles,
Equatorial Guinea and Gabon. These are
largely due to its large petroleum
reserves and low population.[10][11]
Libya has the 10th-largest proven oil
reserves of any country in the world
and the 17th-highest petroleum
production.

…

… I’d like to allow each sentence to be highlightable, such that when a person clicks somewhere within the sentence, the sentence will then appear highlighted (the sentences are already separated when they’re read into the ${text} variable, so I can let ${text} be an array of the sentences if necessary).

This is what the highlighted sentence within the large text should look like:

With an area of almost 1,800,000 square kilometres (700,000 sq mi), Libya is the fourth largest country in Africa by area, and the 17th largest in the world.[9] The capital, Tripoli, is home to 1.7 million of Libya's 6.4 million people. The three traditional parts of the country are Tripolitania, Fezzan, and Cyrenaica. Libya has the highest HDI in Africa and the fourth highest GDP (PPP) per capita in Africa as of 2009, behind Seychelles, Equatorial Guinea and Gabon. These are largely due to its large petroleum reserves and low population.[10][11] Libya has the 10th-largest proven oil reserves of any country in the world and the 17th-highest petroleum production.


The highlighted sentences should be stored, such that I’ll be able to retrieve the highlighted sentences that the person clicks.

I’m thinking that this problem will require .select() from jQuery and various variable containers to sort which sentences are highlighted. If you have any suggestions on how I can go about this, it would be very much appreciated as I’m at stuck on which methods and tools to use. 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-05-23T07:23:39+00:00Added an answer on May 23, 2026 at 7:23 am

    Put each sentence in a span tag. Example:

    <div class="text">
    <span>With an area of almost 1,800,000 square kilometres (700,000 sq mi), Libya is the fourth largest country in Africa by area, and the 17th largest in the world.[9]</span>
    <span>The capital, Tripoli, is home to 1.7 million of Libya's 6.4 million people.</span>
    </div>
    

    Then you can catch the clicks and set a class on the span:

    $('.text span').click(function(){ $(this).toggleClass('selected') });
    

    Use a CSS style to make the selected span appear differently:

    .text .selected { background: #ff9; }
    

    To get the selected sentences, just get the span elements that have the class:

    var sentences = $('.text .selected');
    

    Demo: http://jsfiddle.net/86FXr/

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

Sidebar

Related Questions

I have text stored in a variable which contains several span tags. I want
Given a variable foo of type FooClass* and a member variable in that class
Is there a built-in way to know if a given session variable is a
Given the following idioms: 1) variable = value1 if condition variable = value2 2)
Given a pointer to some variable.. is there a way to check whether it
Given a Generic List of objects that contain a member variable that is a
I have the following query, which performs a full-text search (CONTAINSTABLE) on the Products
How can you transfer a variable such as ask_question in the URL such that
UPDATE: I added an answer to this question which incorporates almost all the suggestions
I have a container div , inside which I want to pack a variable

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.