0
第一個文本框我已經試過這樣做是爲了將焦點設置頁面加載,但它不是重點jQuery的焦點設置上頁面加載
$('#profileForm :input[type=text]:first').focus();
如何設置第一控制forucs在#profileForm
更新:
<div id="profileForm" runat="server" visible="true">
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$('input[type=text], select, textarea').focus(function() {
$(this).removeClass('form-blur');
$(this).addClass('form-focus');
})
$('input[type=text], select, textarea').blur(function() {
$(this).removeClass('form-focus');
$(this).addClass('form-blur');
});
$('#profileForm input[type=text]').first().focus();
});
</script>
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr>
<td class="form-label" style="white-space:nowrap">First Name:</td>
<td>
<asp:TextBox ID="txtFirstName" runat="server" /></td>
<td rowspan="8" style="width:100%; padding-left:10px" valign="top">
<asp:TextBox ID="txtSummary" runat="server" TextMode="MultiLine" Rows="4" Width="99%" /><br />
Summary
</td>
</tr>
</table>
</div>
'input'是不是一個僞類 - 只刪除導致結腸和你應該很好:$('#profileForm input [type = text]')。first()。focus(); – rjz 2012-03-03 04:23:29
它專注於我http://jsfiddle.net/BbSLy/1/ – DG3 2012-03-03 04:24:40
你把它放在$(document).ready(){}裏面嗎? – 2012-03-03 04:25:42