Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function dadada(f, t) {
- var f = $(f);
- var start_tag = "[" + t + "]";
- var end_tag = "[\/" + t + "]";
- if (document.selection) {
- f.focus();
- var selected = document.selection.createRange().text;
- var sel = document.selection.createRange();
- sel.text = start_tag + selected + end_tag;
- } else if (f.selectionStart || f.selectionStart == '0') {
- var startPos = f.selectionStart;
- var endPos = f.selectionEnd;
- var text = start_tag + f.value.substring( startPos, endPos ) + end_tag;
- f.value = f.value.substring(0, startPos) + text + f.value.substring(endPos, f.value.length);
- } else {
- f.value += start_tag + end_tag;
- }
- f.focus();
- }
Add Comment
Please, Sign In to add comment