Skip to main content
edited tags
Link
shybovycha
  • 12.4k
  • 6
  • 54
  • 86
edited tags
Link
user447356
user447356
The Full code that i am using for making the Text Bold
Source Link
Yahoo
  • 4.2k
  • 18
  • 64
  • 85

I want to select text thats is on a Html page and make it BOLD, I am using the following Code

<script type="text/javascript" > function getSelectedText(){ if(window.getSelection){ ; return window.getSelection().toString(); } else if(document.getSelection){; return document.getSelection(); } else if(document.selection){ ; return document.selection.createRange().text; } } $(document).ready(function(){ $("*").live("mouseup", function() { selection = getSelectedText(); alert(selection); if(selection.length >= 3) {   $(this).html($(this).html().replace(selection, "<b>" + selection + "</b>") ); } } ); }); </script> 

This Code works Fine But when the text is in two different paragraphs/ Div or if there is a link between the text then it doesnt seem to work.

How Could i Make it Work ?

I want to select text thats is on a Html page, I am using the following Code

function getSelectedText(){ if(window.getSelection){ ; return window.getSelection().toString(); } else if(document.getSelection){; return document.getSelection(); } else if(document.selection){ ; return document.selection.createRange().text; } } 

This Code works Fine But when the text is in two different paragraphs/ Div or if there is a link between the text then it doesnt seem to work.

How Could i Make it Work ?

I want to select text thats is on a Html page and make it BOLD, I am using the following Code

<script type="text/javascript" > function getSelectedText(){ if(window.getSelection){ ; return window.getSelection().toString(); } else if(document.getSelection){; return document.getSelection(); } else if(document.selection){ ; return document.selection.createRange().text; } } $(document).ready(function(){ $("*").live("mouseup", function() { selection = getSelectedText(); alert(selection); if(selection.length >= 3) {   $(this).html($(this).html().replace(selection, "<b>" + selection + "</b>") ); } } ); }); </script> 

This Code works Fine But when the text is in two different paragraphs/ Div or if there is a link between the text then it doesnt seem to work.

How Could i Make it Work ?

Source Link
Yahoo
  • 4.2k
  • 18
  • 64
  • 85
Loading