0

i have a problem of hand cursor i m currently selecting the text and highlighting it but problem is i want a hand cursor on the highlighting text

here is the running code of the problem any suggestion

http://jsfiddle.net/8mdX4/135/

and i want to run it in the IE8

Librak
  • 141
  • 1
  • 4
  • 15

3 Answers3

0

use this

style="cursor:pointer"
Luke
  • 11,426
  • 43
  • 60
  • 69
Jassi Oberoi
  • 1,424
  • 1
  • 12
  • 25
  • ya u r right but for this u need a div or something on which u can apply css , i have a range object only check that link in the question. – Librak Mar 21 '12 at 06:56
  • create dynamic div tag like this var divTag = document.createElement("div"); divTag.style.cursor = "pointer"; divTag.innerHTML = "Your Content"; document.body.appendChild(divTag); – Jassi Oberoi Mar 21 '12 at 07:09
0

Add a CSS rule in your example:

​span { 
    cursor: pointer;
}​

This will enable the hand-cursor on the generated span element on the page. Preferrabally you'd add an extra class to the generated span so not all span elements get the hand cursor. then you can add that class to the css like:

​span.highlight { 
    cursor: pointer;
}​
Rody
  • 2,675
  • 1
  • 22
  • 40
  • did u check that link...?? actually i dnt have any div or input i have a range object therefore m not able to do this can u pls help me where to put this line to get the cursor. – Librak Mar 21 '12 at 06:55
  • where is it working on ur side give me the link because there is no SPAN tag in my POST... – Librak Mar 21 '12 at 07:09
  • That's right, in Chrome it automatically adds a span class to your text. But, in my opinion, the way to go would be to add a span element using javascript (of JQuery) like: http://stackoverflow.com/questions/2359607/how-do-i-insert-span-tags-into-the-middle-of-text-strings-that-were-generated Then you can just style that span the way you like it. – Rody Mar 21 '12 at 07:16
0

That is not possible using execCommand() as it does not support it. An alternative would be wrap the selected text in <span> tag and set the css property for it but it becomes PITA if you have html tags into your text.

Nonetheless, this might help you: Inserting string at position x of another string

Community
  • 1
  • 1
codef0rmer
  • 10,284
  • 9
  • 53
  • 76