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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:46:22+00:00 2026-06-14T10:46:22+00:00

This is a problem I’m running into and I’m not quite sure how to

  • 0

This is a problem I’m running into and I’m not quite sure how to approach it.

Say I have a paragraph:

"This is a test paragraph. I love cats. Please apply here"

And I want a user to be able to click any one of the words in a sentence, and then return the entire sentence that contains it.

  • 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-14T10:46:24+00:00Added an answer on June 14, 2026 at 10:46 am

    You first would have to split your paragraph into elements, as you can’t (easily) detect clicks on text without elements :

    $('p').each(function() {
        $(this).html($(this).text().split(/([\.\?!])(?= )/).map(
          function(v){return '<span class=sentence>'+v+'</span>'}
       ));
    });
    

    Note that it splits correctly paragraphs like this one :

    <p>I love cats! Dogs are fine too... Here's a number : 3.4. Please apply here</p>​
    

    Then you would bind the click :

    $('.sentence').click(function(){
        alert($(this).text());
    });
    

    Demonstration

    I don’t know if in English : is a separator between sentences. If so, it can be added to the regex of course.

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

Sidebar

Related Questions

This problem is driving me crazy because I am not sure why this just
This problem only occurs on IE8 (not IE8 compatibility mode). I have a file
This problem has bugged me so many times and i have now decided to
This problem is baffling me: BEGIN; INSERT INTO sub_users(user_id, email) SELECT user_id FROM users
This problem is driving me nuts. I have a prototype UITableViewCell in my storyboard.
This problem may be a bug. i have spent too much time trying to
This problem has bothered me for a while and Im sure theres some sort
This problem has been solved before, but I'm just not getting it with examples
This problem has been bugging me for a while. I have to load a
This problem is the bane of my asp.net coding life. I have a control,

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.