Wuu Posted May 28, 2010 Report Share Posted May 28, 2010 (edited) $('#bBold').click(function() { var textarea = document.getElementById("textareas"); var len = textarea.value.length; var start = textarea.selectionStart; var end = textarea.selectionEnd; var sel = textarea.value.substring(start, end); var replace = '[b]' + sel + '[/b]'; textarea.value = textarea.value.substring(0,start) + replace + textarea.value.substring(end,len); }); Vajadzētu atrast iezīmēto tekstu textarea laukā un aplikt to ar tāgiem. Bet ar šādu variantu teksts netiek "aplikts", bet gan viss tekst tiek nomainīts uz jaunu! Labāki varianti ar jQuery palīdzību? Gatavi teksta redaktori neder man vajag tikai 3 pogas :) Edited May 28, 2010 by Wuu Quote Link to comment Share on other sites More sharing options...
Леший Posted May 28, 2010 Report Share Posted May 28, 2010 http://tinyurl.com/37emg3n Quote Link to comment Share on other sites More sharing options...
Wuu Posted May 28, 2010 Author Report Share Posted May 28, 2010 Леший, slimojam? Quote Link to comment Share on other sites More sharing options...
Леший Posted May 28, 2010 Report Share Posted May 28, 2010 Ja tu apskatītos, ko iedevu, tu pirmkārt zinātu, ka tavs kods visdrizāk nestrādās nekur citur, izņemot FF. Otrkārt, tur piemēri ir līdzīgi tavejam, un var sel = textarea.value.substring(start, end); laikam nestrādās, jo ir jāizmanto end - start. Skaties otro linku, tur viss aprakstīts, ir pat gatavs kods, bet atkārtoju, visdrīzāk, strādās tikai FF'ā. Quote Link to comment Share on other sites More sharing options...
Wuu Posted May 28, 2010 Author Report Share Posted May 28, 2010 (edited) Леший, paturi savus minējumus pie sevis. Visiem paldies, pats tiku galā. Edited May 28, 2010 by Wuu Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.