项目____EL、JQuery____加载预处理

来源:互联网 发布:杂志排版设计软件 编辑:程序博客网 时间:2024/04/29 11:56

设置单击查看图片效果为窗口内弹出:

$(document).ready(function() {        $("a#popImg1").fancybox({            'titleShow'        : false,            'transitionIn'    : 'elastic',            'transitionOut'    : 'elastic'        });});


<td style="text-align:left;">    <a id="popImg1" href="${ctx}/${info[img1]}">        <img alt="popImg1" src="${ctx}/${info[img1]}" width="40" height="40"/>    </a></td>


设置文件加载预处理:

(function(){})表示一个匿名函数。function(arg){...}定义了一个参数为arg的匿名函数,然后使用(function(arg){...})(param)来调用这个匿名函数。其中param是传入这个匿名函数的参数。

  需要注意与$(function(){})的区别:$(function(){}) 是 $(document).ready(function(){}) 的简写,用来在DOM加载完成之后执行一系列预先定义好的函数。


设置获取当前时间:

//日期-->String    function formatDate(d) {          return d.getFullYear() + "-" +         (((d.getMonth() + 1)+"").length==1?("0"+(d.getMonth() + 1)):(d.getMonth() + 1)) + "-" +         ((d.getDate()+"").length==1?("0"+d.getDate()):d.getDate());    }    //时间-->String    function formatTime(d) {          return ((d.getHours()+"").length==1?("0"+d.getHours()):d.getHours()) + ":" +         ((d.getMinutes()+"").length==1?("0"+d.getMinutes()):d.getMinutes()) + ":00";     }


function showQAModal() {        resetValidatorForm();        $('#QAModalForm')[0].reset();            $("#id").val("");        $("#QAModalForm").attr("status", "save");        $("#deleteBtn").hide();        $("#hid1").text("新增OGC检查");        $("#date_day").val(formatDate(new Date()));        $("#time_time").val(formatTime(new Date()));        $("#QAModal").modal("show");    }


清空表单:

//清空表单    function clearSearch() {        $(':input','#searchForm')        .not(':button, :submit, :reset, :hidden')        .val('')        .removeAttr('checked')        .removeAttr('selected');    }




0 0
原创粉丝点击