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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:34:59+00:00 2026-05-25T17:34:59+00:00

Similar to what I asked in this question a while back about getting the

  • 0

Similar to what I asked in this question a while back about getting the index of string onClick with Android, I would like to now do the same thing with JavaScript (I’m using the jQuery library if there’s any useful functions for me in there as well). I’ve searched online and Stack Overflow and can’t seem to find anything. My answer in the question I linked deals with (x,y) coordinates and an offset, which I noticed jQuery has, but it seems to give the position of the entire element relative to the document and not the actual (x,y) coordinates. Is there a similar method of getting the (x,y) coordinates with JavaScript (or an even easier way to get the index onClick)? If my question isn’t clear enough, given the following String:

Mary never went to school. Mary was way too cool.

I want to have it so that I can get back 3 if someone clicks on the ‘y’ in the first "Mary" and so on.

As always, any help or a solid direction is greatly appreciated.

  • 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-25T17:34:59+00:00Added an answer on May 25, 2026 at 5:34 pm

    If the text is short enough, it wouldn’t be horrible to wrap each letter in its own <span>.

    Something like:

    var text = $("#clickable-letter-div").html();
    
    var wrapped = $.map(text.match(/./g), function(s, idx){
      return "<span class='letter'>" + s + "</span>"
    }).join("");
    
    $("#clickable-letter-div").html(wrapped);
    
    $(".letter").click(function(){
      var pos = $(this).parent().children().index(this);
      alert(pos);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I previously asked a similar question on this topic a while back and got
I asked a similar question about this previously, but I did not specify that
I asked a similar question here a while back but all the answers were
Okay so I know I asked a similar question a while ago, but this
While this question asked something similar too, I'm interested in this from another angle.
This question is related to this question I asked a little while back. The
I asked a similar question to this awhile back and got zero responses, so
Here is the reason why this question was being asked: www.devplusplus.com/Tests/CSharp/Hello_World . While similar
This question is about a similar javascript scope problem that I asked yesterday .
This is similar to this question I asked last week. My dataGrid is populated

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.