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