替换html中选中的文字

        function replaceSelection() {
if (window.getSelection) {
var selecter = window.getSelection();
var selectStr = selecter.toString();
if (selectStr.trim != "") {
var rang = selecter.getRangeAt(0);
var temp = $("<b>" + selectStr + "<b/>");
rang.surroundContents(temp[0]);
}
} else if (document.selection) {//ie
var selecter = document.selection.createRange();
selecter.select();
var selectStr = selecter.text;
selecter.pasteHTML("<b>" + selectStr + "<b/>");
}
}

  程序员的基础教程:菜鸟程序员

最新文章

  1. Making the Grade(POJ3666)
  2. struts2 action配置时 method 省略不写 默认执行方法是父类ActionSuppot中的execute()方法
  3. (转)UVM内容梗概
  4. Learning JavaScript Design Patterns The Singleton Pattern
  5. Checking Network Configuration requirements Failed
  6. mysql导出表结构
  7. tensorflow初探
  8. 禁用了传说中的PHP危险函数之后,Laravel的定时任务不能执行了?
  9. Javascript初识之流程控制、函数和内置对象
  10. 我在Python学习中遇到的问题一
  11. JAVA核心技术I---JAVA基础知识(类的继承)
  12. JavaScript术语:shim 和 polyfill
  13. 1.4 Chrome浏览器
  14. hook进程
  15. 使用静态库的一些问题 -all_load
  16. CNN-利用1*1进行降维和升维
  17. Android——初学
  18. Dijkstra 调度场算法 Python实现 一
  19. nginx高性能WEB服务器系列之六--nginx负载均衡配置+健康检查
  20. 《从零开始学Swift》学习笔记(Day 24)——枚举

热门文章

  1. NOIP2016参赛总结
  2. WEBPACK开始
  3. C#实现获取文本文件的编码的一个类(区分GB2312和UTF8)-来自转载收集
  4. Sequelize 关系模型简介
  5. python模块之subprocess
  6. centos6.5 用户管理
  7. C# 时间函数相减
  8. 配合crond服务实现自定义周期备份MySQL数据库(使用innobackupex进行备份)
  9. C# iis 错误配置信息( CS0016: 未能写入输出文件 )
  10. jQuery实现瀑布流