JavaScript Why getSelection() always returns nothing?

$("body").on('click', 'button', function(e) {
  var selection =  window.getSelection().toString();
  alert(selection);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea id="txtarea">this is a test</textarea>
<button>click</button>
Answer:1

Consider the following URLs: <http://www.google.com> <http://www.google.com|www.google.com> <http://google.com|google.com> I'm trying to figure a RegEx that would capture the URL ...

Consider the following URLs: <http://www.google.com> <http://www.google.com|www.google.com> <http://google.com|google.com> I'm trying to figure a RegEx that would capture the URL ...

  1. regex capture between two strings
  2. regex capture between quotes
  3. regex capture between brackets
  4. regex capture between two characters
  5. regex capture between parentheses
  6. regex capture between html tags
  7. regex capture between commas
  8. regex capture between two patterns
  9. regex capture between
  10. regex capture between tags
  11. regex capture between spaces
  12. regex capture between strings
  13. regex capture between square brackets
  14. regex capture from to
  15. regex capture from string
  16. regex capture everything between
  17. regex capture group between two characters
  18. regex capture everything between quotes
  19. regex capture text between two strings
  20. regex capture everything between two words

I'm working on a voxel engine that uses WebGL directly. The textures look great within a voxel-engine game (which uses three.js), but look horrible in my engine. Here's an example with a simple grass ...

I'm working on a voxel engine that uses WebGL directly. The textures look great within a voxel-engine game (which uses three.js), but look horrible in my engine. Here's an example with a simple grass ...

Can someone explain why these array methods in Javascript have functions as parameters? An example would be: newArray = oldArray.map( function(val){ return val + 3; }); also this, array.sort(...

Can someone explain why these array methods in Javascript have functions as parameters? An example would be: newArray = oldArray.map( function(val){ return val + 3; }); also this, array.sort(...

I have a simple form here, <?php echo form_open('moneyexchange/invest_first_page'); ?> <input id="amount" value="" type="text" placeholder="Amount in &euro;" name="writtenamount"/&...

I have a simple form here, <?php echo form_open('moneyexchange/invest_first_page'); ?> <input id="amount" value="" type="text" placeholder="Amount in &euro;" name="writtenamount"/&...