0

How to double click on partial value of the text from a element using javascript.

Example:

Site : https://www.crm.com/resource-category/all/
Xpath of Html element : (//div[@class='col-12 offset-md-1 col-md-11'])[2]
text value : Helpful resources to get you oriented around CRM.COM

Now, I want to go to the above Site and get the text of the element with the above xpath. until this point its fine. Its a tag with simple text. But now, I want to double click on the partial text of the div element which is "Resources" in javascript

Attached image. tag has whole text value as "Helpful resources to get you oriented around CRM.COM" but I want code to double click the partial text which can be "resources to get".

please help Inspected value on the website

Priyanka
  • 1
  • 1
  • Can you explain what you are actually intending to do ? – Dani Jul 07 '21 at 07:04
  • How is this presented in the page? How do you load the page? Is this a scraping of this page or do you need a bookmarklet or user script? – mplungjan Jul 07 '21 at 07:04
  • 1
    Welcome to Stack Overflow! Visit the [help], take the [tour] to see what and [ask]. if you get stuck, post a [mcve] of your attempt, noting input and expected output using the [`[<>]`](https://meta.stackoverflow.com/questions/358992/ive-been-told-to-create-a-runnable-example-with-stack-snippets-how-do-i-do) snippet editor. – mplungjan Jul 07 '21 at 07:05
  • Your question is not clear, a good advice, always try to come up with an example code so that people understand what you are trying to do. – skr Jul 07 '21 at 07:10
  • Is it a button or anchor link? – skr Jul 07 '21 at 07:11
  • https://stackoverflow.com/questions/18399215/how-to-programmatically-fire-a-dblclick-event-defined-with-addeventlistener check this one – Abhinav Kumar Jul 07 '21 at 11:09
  • @skr, Its a simple text element within
    tag. when I double click on partial text, a popup appears and I need to automate the scenario. Thanks
    – Priyanka Jul 07 '21 at 15:24
  • Can you inspect the `Resources` text and attach the image in your question? – skr Jul 07 '21 at 15:46
  • @skr, added the image and also the expected outcome – Priyanka Jul 08 '21 at 04:46

1 Answers1

0

@skr, Its a simple text element within tag. when I double click on partial text, a popup appears and I need to automate the scenario. Thanks –

Here is what you asked. I used jQuery, but you can use vanilla if you want.

$('.clickable span').click(function(){
  alert('do something');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="clickable">
<p>A small text so you can <span><u>click here</u></span></p>
</div>
Alexis Garcia
  • 452
  • 3
  • 15