读书人

表单验证,定位到第一个异常提示的地方

发布时间: 2012-08-28 12:37:01 作者: rapoo

表单验证,定位到第一个错误提示的地方

//js锚点定位

//定位到第一个错误提示的地方

//定位到第一个验证提示的地方

//查找所有class为tip,且内容不为空的元素

//$(".tip").filter(function(){return $.trim($(this).text()) != ""}) 返回集合;

function  toFirstTip(){    //  alert($(".tip").filter(function(){return $.trim($(this).text()) != ""}).size());    if($(".tip").filter(function(){return $.trim($(this).text()) != ""}).size()>0){       var firstTip=$(".tip").filter(function(){return $.trim($(this).text()) != ""}).eq(0);       var firstTipId=firstTip.attr("id");      if( $.trim(firstTipId)==""){        firstTipId="firstTip";        $(".tip").filter(function(){return $.trim($(this).text()) != ""}).eq(0).attr("id",firstTipId);       }      $("#"+firstTipId).closest(".wrappedTables").css("display","block");      window.location.href="#"+firstTipId;    }}

?

读书人网 >Web前端

热点推荐