js/jqte/uncompressed/jquery-te-1.4.0.js
function replaceSelection(tTag,tAttr,tVal) {
				
				// first, prevent to conflict of different jqte editors
				if(editor.not(":focus"))
					editor.focus();
				
				// for webkit, mozilla, opera			
				if (window.getSelection)
				{
					var selObj = selectionGet(), selRange, newElement, documentFragment;
					
					if (selObj.anchorNode && selObj.getRangeAt)
					{
						selRange = selObj.getRangeAt(0);
						
						// create to new element
						newElement = document.createElement(tTag);
						
						// add the attribute to the new element
						$(newElement).attr(tAttr,tVal);
						
						// extract to the selected text
						documentFragment = selRange.extractContents();
						
						// add the contents to the new element
						newElement.appendChild(documentFragment);
						
						selRange.insertNode(newElement);
						selObj.removeAllRanges();
						
						// if the attribute is "style", change styles to around tags
						if(tAttr=="style")
							affectStyleAround($(newElement),tVal);
						// for other attributes
						else
							affectStyleAround($(newElement),false);
					}
				}
				// for ie
				else if (document.selection && document.selection.createRange && document.selection.type != "None")
				{
					var range = document.selection.createRange();
					var selectedText = range.htmlText;
					
					var newText = '<'+tTag+' '+tAttr+'="'+tVal+'">'+selectedText+'</'+tTag+'>';
					
					document.selection.createRange().pasteHTML(newText);
				}
			}
function replaceSelection(tTag,tAttr,tVal) {
				
				// first, prevent to conflict of different jqte editors
				if(editor.not(":focus"))
					editor.focus();
				
				// for webkit, mozilla, opera			
				if (window.getSelection)
				{
					var selObj = selectionGet(), selRange, newElement, documentFragment;
					
					if (selObj.anchorNode && selObj.getRangeAt)
					{
						selRange = selObj.getRangeAt(0);
						
						// create to new element
						newElement = document.createElement(tTag);
						
						// add the attribute to the new element
						$(newElement).attr(tAttr,tVal);
						
						// extract to the selected text
						documentFragment = selRange.extractContents();
						
						// add the contents to the new element
						newElement.appendChild(documentFragment);
						
						selRange.insertNode(newElement);
						selObj.removeAllRanges();
						
						// if the attribute is "style", change styles to around tags
						if(tAttr=="style")
							affectStyleAround($(newElement),tVal);
						// for other attributes
						else
							affectStyleAround($(newElement),false);
					}
				}
				// for ie
				else if (document.selection && document.selection.createRange && document.selection.type != "None")
				{
					var range = document.selection.createRange();
					var selectedText = range.htmlText;
					
					var newText = '<'+tTag+' '+tAttr+'="'+tVal+'">'+selectedText+'</'+tTag+'>';
					
					document.selection.createRange().pasteHTML(newText);
				}
			}
function replaceSelection ( tTag , tAttr , tVal ) { // first, prevent to conflict of different jqte editors
 if ( editor . not ( ":focus" ) ) editor . focus ( ) ; // for webkit, mozilla, opera			
 if ( window . getSelection ) { var selObj = selectionGet ( ) , selRange , newElement , documentFragment ; if ( selObj . anchorNode && selObj . getRangeAt ) { selRange = selObj . getRangeAt ( 0 ) ; // create to new element
 newElement = document . createElement ( tTag ) ; // add the attribute to the new element
 $ ( newElement ) . attr ( tAttr , tVal ) ; // extract to the selected text
 documentFragment = selRange . extractContents ( ) ; // add the contents to the new element
 newElement . appendChild ( documentFragment ) ; selRange . insertNode ( newElement ) ; selObj . removeAllRanges ( ) ; // if the attribute is "style", change styles to around tags
 if ( tAttr == "style" ) affectStyleAround ( $ ( newElement ) , tVal ) ; // for other attributes
 else affectStyleAround ( $ ( newElement ) , false ) ; } } // for ie
 else if ( document . selection && document . selection . createRange && document . selection . type != "None" ) { var range = document . selection . createRange ( ) ; var selectedText = range . htmlText ; var newText = '<' + tTag + ' ' + tAttr + '="' + tVal + '">' + selectedText + '</' + tTag + '>' ; document . selection . createRange ( ) . pasteHTML ( newText ) ; } }
the function of changing to the selected text with tags and tags's attributes
the function of changing to the selected text with tags and tags s attributes