我正在使用弹出框添加类别。脚本是
<script>
function changeMenu(id)
{
if (id=='other')
{ //Getting the variable's value from a link
var loginBox = 'login-box';
$('#login-box').fadeIn(300);
var popMargTop = ($('#login-box').height() + 24) / 2;
var popMargLeft = ($('#login-box').width() + 24) / 2;
$('#login-box').css({
'margin-top' : -popMargTop,
'margin-left' : -popMargLeft
});
$('body').append('<div id="mask"></div>');
return false;
}
}
</script>
弹出窗口的 html 是
<div id="login-box" class="login-popup">
<script>
// When clicking on the button close or the mask layer the popup closed
$('a.close, #mask').live('click', function() {
$('#mask , .login-popup').fadeOut(300 , function() {
$('#mask').remove();
});
return false;
});
</script>
<a href="#" class="close"><img src="images/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>
<form method="post" class="signin" action="#" name="catform" id="catform">
<table align="center" width="500" height="200" class="border2">
<tbody><tr>
<td bgcolor="#cccccc" align="center" class="txt_users">
Add</td></tr>
<tr bgcolor="#ffffff">
<td align="center" colspan="2"><font color="#ff0000">
</font>
</td></tr>
<tr bgcolor="#eeeee1">
<td align="center"><span class="txt_sitedetails">
Name</span>
<input type="text" style="width: 300px;" value="" name="cat" id="cat" class="cat">
<input type="hidden" value="1" name="cate">
<input type="hidden" value="" name="mode">
<input type="hidden" value="" name="id">
<br><br><input type="submit" onclick="return val();" class="button" value="Submit" name="add">
</td></tr>
</tbody></table>
</form>
</div>
我必须将重点放在弹出窗口中的名称文本字段上。我尝试了以下脚本
<script type="text/javascript" language="JavaScript">
document.forms['catform'].elements['cat'].focus();
</script>
<script language="Javascript">
document.catform.cat.focus()
</script>
<script language="javascript">
$(function() {
$('input.cat').focus();
});
</script>
但它们都不起作用