$("input[id='txtJE']:first").focus();或是
$("input[id='txtJE']").eq(0).focus();

解决方案 »

  1.   

    $(function(){
        $("input[name='txtJE']:first").focus();});
      

  2.   

    不知道你实际的测试环境,我提供的两种方法都是可行的,用
    $("input[pp='tt']:first").focus();
    也是可以的,只是没必要加这么一个非标准化的属性
      

  3.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
     <head>
      <title> New Document </title>
      <meta name="Generator" content="EditPlus">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
     </head>
    <script type="text/javascript">
    function start(){
    var firstInput=document.getElementsByTagName("input")[0];
    firstInput.select();
    }
    </script>
     <body onload="start();">
    <label>text1:</label>  <input type="text" /><br/>
    <label>text2:</label>  <input type="text" /><br/>
    <label>text3:</label>  <input type="text" /><br/>
    <label>text4:</label>  <input type="text" /><br/>
     </body>
    </html>
    给LZ一个Demo,它可以在页面加载时指定一个文本框出现光标。
      

  4.   

    忘了说明一下,我有用框架frame,左右两栏,点左边那栏,右边打开一个网页,这个网页就是我要控制焦点的页面。
      

  5.   

    <input id="txtJE" name="txtJE" maxlength="15" pp="tt" type="text" t_value="" o_value="" 
                                        svalue="<%# DataBinder.Eval(Container.DataItem, "ptdtmx_je") %>" ivalue="<%# DataBinder.Eval(Container.DataItem, "ptdtmx_srje") %>" isright="<%# DataBinder.Eval(Container.DataItem, "ptdtmx_df") %>" te="" 
                                        style="width:150px; font-size:12px; padding-top:3px;border:0px none white;height:15px; line-height:15px; text-align:right; background-color:#CCE8CF;" 
                                        value='<%# ((double)(DataBinder.Eval(Container.DataItem, "ptdtmx_srje"))==0)?"":string.Format("{0:N"+iXXW+"}", ((Double)(DataBinder.Eval(Container.DataItem, "ptdtmx_srje"))))%>' 
                                        onKeyPress="fkeyPress(this);" onkeyup="fkeyUp(this);" onfocus="fonFocus(this);" onblur="fonBlur(this);"  />大家的思路都给你了,单例都可以使用,用到你那不行了,你就应该自己去找问题在哪里。而不是把问题丢回来给别人,坐享其成。检查你自己的函数去吧。我只是本着有始有终的原则再次回答你这个问题。拒绝这种不劳而获的人
    或许:$("input[name='txtJE']:first").select();可以实现你的效果,你的fonFocus中setSelection在我这里无法执行
      

  6.   

    document.getElementById('Id名').focus();