编辑内容

怼烎@ 2022-08-18 12:23 285阅读 0赞

点击编辑显示编辑框,确定则保存内容,取消则还原

效果图:20151121111350758

使用bootstrap,font awesome ,alertfly 或者是 alertflyjs 两个版本。

使用alertfly目的是当输入内容为null时友情提示,其提示框不可拖拽,而alertflyjs是可拖拽。

使用font awesome目的是用图标代替文字,跟简洁

代码:

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=GBK">
  5. <!--当前页面的三要素-->
  6. <title>内容修改</title>
  7. <meta name="Keywords" content="关键词,关键词">
  8. <meta name="Description" content="">
  9. <!--css,js-->
  10. <style type="text/css">
  11. *{margin:0;padding:0;}
  12. #box {width:300px;height:300px;margin:50px auto;border:2px solid #ccc;border-radius:4px;}
  13. #box .item{text-align:center;}
  14. #box .button , .edit{display:none;color:blue;}
  15. </style>
  16. <link type="text/css" rel="stylesheet" href="bootstrap/3.3.0/css/bootstrap.min.css" ></link>
  17. <link type="text/css" rel="stylesheet" href="font-awesome/4.3.0/css/font-awesome.min.css" />
  18. <link type="text/css" rel="stylesheet" href="alertify/0.3.12/css/alertify-bootstrap.css"/>
  19. <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
  20. <script type="text/javascript" src="bootstrap/3.3.0/js/bootstrap.min.js" ></script>
  21. <script type="text/javascript" src="alertify/0.3.12/js/alertify.js"></script>
  22. </head>
  23. <body>
  24. <div id="box">
  25. <div class="item">
  26. <div class="name" title="ITDragon">ITDragon</div>
  27. <i class="edit fa fa-pencil fa-lg"></i>
  28. <i class="button save fa fa-check fa-lg"></i>
  29. <i class="button cancle fa fa-times fa-lg"></i>
  30. </div>
  31. </div>
  32. <script type="text/javascript">
  33. $(function(){
  34. $("#box").find(".edit").click(function(){
  35. var $name = $(this).parent().find(".name");
  36. $(this).hide();
  37. $(this).parent().find(".button").show();
  38. var text = $name.text();
  39. $name.html("<input type='text' class='newText' value='"+text+"'/>");
  40. });
  41. $("#box").find(".cancle").click(function(){
  42. var $name = $(this).parent().find(".name");
  43. $name.html($name.attr("title"));
  44. $(this).parent().find(".button").hide();
  45. $(this).parent().find(".edit").show();
  46. });
  47. $("#box").find(".save").click(function(){
  48. var $name = $(this).parent().find(".name");
  49. var $input = $(this).parent().find(".newText");
  50. var inputValue = $input.val();
  51. if(inputValue != ""){
  52. $name.attr("title" ,inputValue).html(inputValue);
  53. $(this).parent().find(".button").hide();
  54. $(this).parent().find(".edit").show();
  55. }else {
  56. alertify.alert("请输入内容");
  57. }
  58. });
  59. });
  60. </script>
  61. </body>
  62. </html>

资源下载地址:http://download.csdn.net/detail/qq_19558705/9288037
转载请注明来源:http://blog.csdn.net/qq_19558705/article/details/49851879

更多干货等你来拿 http://www.itit123.cn/

发表评论

表情:
评论列表 (有 0 条评论,285人围观)

还没有评论,来说两句吧...

相关阅读

    相关 在线编辑Word——插入内容控件

    内容控件是可添加和自定义的以在模板、窗体和文档中使用的单个控件。Word中支持添加多种类型的控件用于不同文档的设计需求。本文,将通过在线编辑的方式展示如何在Word中插入内容控

    相关 编辑内容

    点击编辑显示编辑框,确定则保存内容,取消则还原 效果图:![20151121111350758][] 使用bootstrap,font awesome ,aler