var app = { config: config || {}, // 简单的点击实现元素展开和收缩的功能 clicktoggle: function(elea,eleb){ $(elea).click(function(){ if(!$(eleb).is(':visible')){ $(this).addclass('clicked'); $(eleb).slidedown(); }else{ $(this).removeclass('clicked'); $(eleb).slideup(); } }) }, //返回顶部 backtop: function(ele,time){ $(ele).click(function () { $('html, body').animate({ scrolltop:'0' },time); }) }, // tab 切换 tabs: function(tabs, tab_box, _event) { $(tab_box).hide(); $(tab_box).eq(0).show(); $(tabs).eq(0).addclass('on'); $(tabs).bind(_event,function(){ $(this).addclass("on").siblings().removeclass("on"); var _index = $(this).index(); $(tab_box).eq(_index).show().siblings().hide(); }) }, // 是否支持 placeholder 属性 placeholdersupport: function () { return 'placeholder' in document.createelement('input'); }, // ie9 兼容 placeholder ieplaceholder: function () { $("[placeholder]").each(function(){ var _this = $(this); _this.wrapall('
'); var left = _this.css("padding-left"); _this.parent().append('' + _this.attr("placeholder") + ''); if(_this.val() != ""){ _this.parent().find("span.placeholder").hide(); } else{ _this.parent().find("span.placeholder").show(); } }).on("focus", function(){ $(this).parent().find("span.placeholder").hide(); }).on("blur", function(){ var _this = $(this); if(_this.val() != ""){ _this.parent().find("span.placeholder").hide(); } else{ _this.parent().find("span.placeholder").show(); } }); // 点击表示placeholder的标签相当于触发input $("span.placeholder").on("click", function(){ $(this).hide(); $(this).siblings("[placeholder]").trigger("click"); $(this).siblings("[placeholder]").trigger("focus"); }); $("input[name='checkcode']").css('width', '100%').parents('.input-box').css('display','inline-block'); }, // 防复制代码 anticlone: function () { // 防止ctrl+c document.onkeydown = function (e) { var e = e || event; if (e.ctrlkey == 1 && e.keycode == 67) { return false; } }; // 阻止复制 document.body.oncopy = function (){ return false; }; //禁止选取 document.body.onselectstart=document.body.oncontextmenu=function(){return false;}; }, };