how2j.cn

步骤 1 : 点击显示用户留言输入框效果   
步骤 2 : 点击显示用户留言输入框效果 js讲解   

步骤 1 :

点击显示用户留言输入框效果

点击输入框的时候,出来一个边框是橘黄色的文本域
"); window.frames["iframe_show3321"].document.write(decodeHtml($("textarea#stepcodeTextarea3321").val())); window.frames["iframe_show3321"].document.close(); $(window.frames["iframe_show3321"]).load(function(){ $("#iframe_show3321").height($("#iframe_show3321").contents().find("body").height()+showittryitheight); }); $("#iframe_show3321").height($("#iframe_show3321").contents().find("body").height()+showittryitheight); setTimeout(function(){ },500); });
运行效果
<!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script> <link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet"> <script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script> </head> <style> body{ font-size: 12px; font-family: Arial; } a{ color:#999; } a:hover{ text-decoration:none; color: #C40000; } div.address { margin: 20px 5px; text-align: left; } tr.orderItemTR td { border-bottom: 1px solid #E5E5E5; } div.buyPageDiv { margin: 20px auto; max-width: 1013px; } table.addressTable { margin: 20px 20px; width: 600px; } span.wangwangGif { display: inline-block; width: 25px; height: 25px; background-image: url(../..../../../img/site/wangwang.gif); background-repeat: no-repeat; background-color: transparent; background-attachment: scroll; background-position: -83px -0px; position: relative; top: 8px; left: 2px; } th.productListTableFirstColumn { text-align: left !important; } tbody.productListTableTbody td { text-align: center; } img.tmallbuy { width: 15px; } table.addressTable td input { border: 1px solid #AFAFAF; width: 200px; } div.orderItemTotalSumDiv { margin: 40px; height: 40px; } table.productListTable th { color: #999999; font-family: 宋体; font-weight: normal; font-size: 12px; text-align: center; padding-bottom: 5px; } table.addressTable td { color: #333333; text-align: right; vertical-align: top; padding-right: 5px; text-align: left; height: 30px; } div.orderItemSumDiv span { color: #999999; } a.marketLink:hover { color: black; font-size: 12px; text-decoration: underline; font-family: 宋体; font-weight: normal; } td.orderItemProductInfo img { height: 16px; } table.addressTable td.firstColumn { width: 100px; } table.productListTable tr.rowborder td { background-color: #b2d1ff; border-right: 2px solid #fff; height: 3px; } span.orderItemProductPrice, span.orderItemProductNumber { color: #000000; } a.marketLink { color: black; font-size: 12px; font-family: 宋体; font-weight: normal; } button.submitOrderButton { border: 1px solid #C40000; background-color: #C40000; text-align: center; line-height: 40px; font-size: 14px; font-weight: 700; color: white; float: right; } label.orderItemDeliveryLabel { color: #666666; font-family: 宋体; font-size: 12px; font-weight: normal; } tr.orderItemTR td { padding: 10px 0px; } td.orderItemProductInfo { text-align: left; } table.productListTable { width: 100%; border-collapse: separate; } table.addressTable td textarea { border: 1px solid #AFAFAF; margin-bottom: 10px; width: 400px; } span.leaveMessageTextareaSpan { display: inilne-block; } a.orderItemProductLink:hover { color: #666666; text-decoration: underline; } tbody.productListTableTbody td.orderItemFirstTD { text-align: left; } textarea.leaveMessageTextarea { border: 1px solid #FFAD35; width: 250px; height: 60px; resize: none; } td.orderItemFirstTD, td.orderItemLastTD { border-bottom: 0px solid black !important; } div.addressTip, div.productListTip { color: #333333; font-size: 16px; font-weight: bold; text-align: left; margin-bottom: 30px; } div.orderItemSumDiv { padding: 20px; border-top: 2px solid #B4D0FF; background-color: #F2F6FF; height: 50px; } div.orderItemTotalSumDiv span { color: #999999; } div.submitOrderDiv { height: 40px; margin: 20px 0px; } div.buyPageDiv button { display: inline-block; margin: 0px 10px; width: 180px; height: 40px; } span.orderItemTotalSumSpan { color: #C40000 !important; font-size: 22px; font-weight: bold; border-bottom: 1px dotted #F2F6FF; } span.orderItemUnitSum { color: #CC0000; font-weight: bold; } tbody.productListTableTbody td.orderItemProductInfo { text-align: left; } a.orderItemProductLink { color: #666666; display: block; } td.orderItemProductInfoPartTD { border-bottom: solid 1px #ECECEC; } select.orderItemDeliverySelect { width: 100px; height: 23px; } span.leaveMessageText { display: inilne-block; margin-right: 10px; float: left; } span.redStar { color: red; font-size: 8px; } img.orderItemImg { width: 50px; height: 50px; border: 1px solid #E9E9E9; } </style> <script> $(function(){ $("img.leaveMessageImg").click(function(){ $(this).hide(); $("span.leaveMessageTextareaSpan").show(); $("div.orderItemSumDiv").css("height","100px"); }); }); </script> <div class="buyPageDiv"> <div class="productList"> <div class="orderItemSumDiv"> <div class="pull-left"> <span class="leaveMessageText">给卖家留言:</span> <span> <img src="http://127.0.0.1/tmall../../../img/site/leaveMessage.png" class="leaveMessageImg"> </span> <span class="leaveMessageTextareaSpan" style="display: none;"> <textarea class="leaveMessageTextarea" name="userMessage"></textarea> <div> <span>还可以输入200个字符</span> </div> </span> </div> <span class="pull-right">店铺合计(含运费): ¥9,152.25</span> </div> </div> </div> <div style="height:100px"></div>
"); window.frames["iframe3321"].document.write(decodeHtml(code3321)); window.frames["iframe3321"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3321"]).load(function(){ $("#iframe3321").height($("#iframe3321").contents().find("body").height()+showittryitheight); }); $("#iframe3321").height($("#iframe3321").contents().find("body").height()+showittryitheight); alreadyWriteCode3321 = code3321; $("#rendering3321").hide(); $("#rendered3321").show(); } var tRereshRetry2DemoPanel3321 = setInterval(rereshRetry2DemoPanel3321,1000); var binded3321 = false; $("textarea#stepcodeTextarea3321").keyup(function(){ if(!binded3321){ $(window).bind('beforeunload',function(){ binded3321 = true; return "xxxx"; }); } var newCode = $(this).val() code3321 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code3321!=newCode){ // window.frames["iframe3321"].document.write("
"); // window.frames["iframe3321"].document.write(decodeHtml($("textarea#stepcodeTextarea3321").val())); // window.frames["iframe3321"].document.close(); // $(window.frames["iframe3321"]).load(function(){ // $("#iframe3321").height($("#iframe3321").contents().find("body").height()+showittryitheight); // }); // code3321 = newCode; // } }); $(".tryButton3321").click(function(){ $("#tryDiv3321").show(); $("#stepcodeTextarea3321").focus(); $("#stepcodeTextarea3321").height(200); $("#iframe3321").height(0); window.frames["iframe3321"].document.write("
"); window.frames["iframe3321"].document.write(decodeHtml($("textarea#stepcodeTextarea3321").val())); window.frames["iframe3321"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3321"]).load(function(){ $("#iframe3321").height($("#iframe3321").contents().find("body").height()+showittryitheight); }); $("#iframe3321").height($("#iframe3321").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor3321.focus(); editor3321.setSize(null, "250"); $("#rendering3321").hide(); $("#rendered3321").hide(); }); var mixedMode = { name: "htmlmixed", scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i, mode: null}, {matches: /(text|application)\/(x-)?vb(a|script)/i, mode: "vbscript"}] }; var editor3321 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3321"), { lineNumbers: true, styleActiveLine: true, matchBrackets: true, mode:"text/html", theme:"eclipse", selectionPointer: true, lineWrapping: true, extraKeys: { "Alt-/": "autocomplete", "Ctrl-F": "findPersistent", "F8": function(cm) { cm.setOption("fullScreen", !cm.getOption("fullScreen")); }, "Esc": function(cm) { if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false); } } }); editor3321.on("change",function(doc){ if(!binded3321){ $(window).bind('beforeunload',function(){ binded3321 = true; return "xxxx"; }); } var newCode = doc.getValue(); code3321 = newCode; $("textarea#stepcodeTextarea3321").val(newCode); if(alreadyWriteCode3321!=code3321){ lastModifedTime3321 = new Date().getTime(); $("#rendering3321").show(); $("#rendered3321").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor3321 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor3321.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv3321").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


源代码
1. 双击选中单词 2. 三击选中整行 3. CTRL+F 查找 4. F8 全屏编辑,再次点击恢复
渲染中 渲染完成
效果
步骤 2 :

点击显示用户留言输入框效果 js讲解

增值内容,请先登录


HOW2J公众号,关注后实时获知布最新的教程和优惠活动,谢谢。


关于 实践项目-天猫前端-交互 的提问

尽量提供截图代码异常信息,有助于分析和解决问题。 也可进本站QQ群交流: 620943819
提问尽量提供完整的代码,环境描述,越是有利于问题的重现,您的问题越能更快得到解答。
对教程中代码有疑问,请提供是哪个步骤,哪一行有疑问,这样便于快速定位问题,提高问题得到解答的速度
在已经存在的几千个提问里,有相当大的比例,是因为使用了和站长不同版本的开发环境导致的,比如 jdk, eclpise, idea, mysql,tomcat 等等软件的版本不一致。
请使用和站长一样的版本,可以节约自己大量的学习时间。 站长把教学中用的软件版本整理了,都统一放在了这里, 方便大家下载: http://how2j.cn/k/helloworld/helloworld-version/1718.html

上传截图