1、标题固定页面顶端
HTML页面: <!--150410--> <div class="xqbox" id="title1"> <div class="pd10"> <h1>{$result.sItemName}</h1> <p class="f999 f12"> <span class="tap flor"><i class="gray">{$result.sAuditState}</i></span>更新时间:{$result.dPublishTime} </p> </div> </div> <div class="xqbox" id="title2" style="position:fixed;100%;top:0;left:0;z-index:9;display:none;"> <div class="pd10"> <h1>{$result.sItemName}</h1> <p class="f999 f12"> <span class="tap flor"><i class="gray">{$result.sAuditState}</i></span>更新时间:{$result.dPublishTime} </p> </div> </div> <!--150410 end--> JS页面: // 标题固定页面顶端 $(window).on('scroll',function(){ if(document.body.scrollTop>130 || document.documentElement.scrollTop>130){ $('#title2').css('display','block'); $('#title1').css('visivility','hidden'); }else{ // alert(456); $('#title2').css('display','none'); $('#title1').css('visibility','visible'); } });
2、localstorage
html页面: <input type="hidden" data-id="zhaopaiStorage" value="id~{$result.sParcelID};title~{$result.sParcelName};district~{$result.sParcelArea}~{$result.sParcelAreaCity}~{$result.sParcelAreaDis};class~1|" /> js页面: define(function(require,exports,module){ "use strict"; module.exports = function(options){ var $ = require("jquery"); var vars = seajs.data.vars; $("input[type=hidden]").each(function(index,element){ vars[$(this).attr('data-id')] = element.value; }); //设置localstorage var storage = window.localStorage; // 当localstorage为空时第一次存 if(!storage.tudi_view_History){ storage.setItem('tudi_view_History',vars.tudiStorage); } // 判断localstorage中是否已存在 if(storage.tudi_view_History.indexOf(vars.tudiStorage)==-1){ storage.tudi_view_History = storage.getItem('tudi_view_History')+vars.tudiStorage; } } });
3、自动聚焦
//自动聚焦 $("#textarea").focus();