$('.text').focus();定位的话直接获取焦点或者设置一个样式就行了。。可以给有问题的加个红框啦。。等等

解决方案 »

  1.   

    <html>
    <head>
    <style>
    .tttt {
    border-width:1px;
    border-color:red;
    }
    </style>
    </head>
    <body>
    <input type="button" id ="test" value="test" />
    <input type="text" id = "tt" />
    <select id ="sl">
    <option></option>
    <option>t1</option>
    <option>t2</option>
    <option>t3</option>
    </select>
    <script type="text/javascript" src ="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.min.js"></script>
    <script language="javaScript">
     $(document).ready(function(){
    $("#test").click(function(){
    var tx = $("#tt").val();
    if(tx === "")
    {
    $("#tt").addClass("tttt");
    }
    else
    {
    $("#tt").removeClass("tttt");
    }
    var sl = $("#sl").val();
    if(sl === "")
    {
    $("#sl").addClass("tttt");
    }
    else
    {
    $("#sl").removeClass("tttt");
    }
    });
       });
    </script>
    </body>
    </html>
      

  2.   

    var target = $('.text');  //自行替換
    $(document).scrollTop(target.offset().top);  //頁面捲動至目標
      

  3.   

    错误时候直接调用$('.text').focus();就行了咩。。
    楼上的方法也可以