JavaScript Text selection visible in alert(), but not in html() text selection not visible in illustrator,adobe illustrator text selection

I got a variable using document.getSelection()

This variable is well displayed if I use alert() but not if I use html().

How can I make it visible with html()?

$(document).ready(function(){
$(".sentence").dblclick(function(){
        var selected_word = document.getSelection();
        $("#word_to_be_showned_in").html(selected_word);
        alert(selected_word);
});
});
<p class="sentence">have a try</p>
<p>Selected word should appear here: <span id="word_to_be_showned_in">XXX</span></p>

Example (compatible with chrome): http://js.do/code/38012

Answer:1

getSelection() returns an object, not a string. Add .toString() to get its text:

var selected_word = document.getSelection().toString();
$("#word_to_be_showned_in").html(selected_word);
alert(selected_word);

Fixed example: http://js.do/code/38017

Answer:2

I am trying to understand the code snippet to create tabs dynamically in my asp.net web application. I am a novice in JQuery, I understood that "tabsDiv.tabs("add", '#main', pages[i][0]);" is ...

I am trying to understand the code snippet to create tabs dynamically in my asp.net web application. I am a novice in JQuery, I understood that "tabsDiv.tabs("add", '#main', pages[i][0]);" is ...

  1. jquery create tabs
  2. jquery create tabs dynamically
  3. jquery tabs create event
  4. jquery tabs tutorial
  5. jquery create new tabs

I have one drop-down its contain DataType. and one text-box this this is for enter Regex Pattern. if I am enter /test/ in textbox. or select from drop-down Int then its wrong pattern if enter in ...

I have one drop-down its contain DataType. and one text-box this this is for enter Regex Pattern. if I am enter /test/ in textbox. or select from drop-down Int then its wrong pattern if enter in ...

I want to check if network connection exists at runtime in javascript. I am using window.navigator.onLine but its not working. <script language="javascript"> alert(window.navigator.onLine); &...

I want to check if network connection exists at runtime in javascript. I am using window.navigator.onLine but its not working. <script language="javascript"> alert(window.navigator.onLine); &...

  1. check network connection speed
  2. check network connection android
  3. check network connection linux
  4. check network connection mac
  5. check network connection iphone
  6. check network connection (-137)
  7. check network connection ubuntu
  8. check network connection directv
  9. check network connection (-7)
  10. check network connection 106
  11. check network connection speed windows 10
  12. check network connection windows 10
  13. check network connection and system time
  14. check network connection on lg smart tv
  15. check network connection command prompt
  16. check network connection powershell
  17. check network connection centos 7
  18. check network connection on ipad
  19. check network connection swift
  20. check network connection python

I'm using a MacBook Air and have been looking into ePub creation. I've taken a copy of the epub3 boilerplate from github click here. I have in a javascript file added the following var txt = document....

I'm using a MacBook Air and have been looking into ePub creation. I've taken a copy of the epub3 boilerplate from github click here. I have in a javascript file added the following var txt = document....

  1. epub javascript library
  2. epub javascript example
  3. epub javascript reader
  4. epub javascript support
  5. epub javascript book
  6. javascript epub viewer
  7. javascript epub parser
  8. javascript epub editor
  9. javascript epub free
  10. javascript epub reader open source
  11. javascript epub creator
  12. javascript epub tutorial
  13. epub reader javascript library
  14. epub cfi javascript
  15. epub 3 javascript
  16. read epub javascript
  17. ibooks epub javascript
  18. eloquent javascript epub
  19. speaking javascript epub
  20. effective javascript epub