Jquery focus()和blur()对我的href不起作用.为什么
jquery focus() and blur() don't work for my href. why?
我有一个链接在我的html:
<a id="mnRoles" href="SysRoles.aspx">Roles</a>
这里有更多的html:
<tr><td style="vertical-align:top;width:33%;">
<table cellpadding="0" cellspacing="0" class="MenuTable">
<tr><th>HRM</th></tr>
<tr><td><a id="mnRoles" href="SysRoles.aspx">Roles</a></td></tr>
<tr><td><a id="mnFunctions" href="SysFunctions.aspx">Function rights</a></td></tr>
<tr><td><a id="mnRegionalOptions" href="MenuCustomize.aspx">Regional options</a></td> </tr>
</table></td></tr></table>
<script>sysPageUrl='logposmanagement.aspx'</script></form>
</body>
</html>
和我试图设置焦点到它(或模糊另一个)通过jQuery像这样:
<script>
$(document).ready(function(){
$("#mnRoles").blur();
$("#mnFunction").focus();
});
</script>
但它不起作用。知道为什么吗?提前感谢!
(我问这个问题的原因是:我希望在加载页面时将焦点设置为我选择的特定链接(通过jQuery)。我不能修改任何HTML或css)。有人能帮帮我吗?谢谢!)
Working jsFiddle Demo
你的链接是:
<a id="mnFunctions" href="SysFunctions.aspx">Function rights</a>
注意,id是mnFunctions
,但在你的jQuery代码中,你写:
$("#mnFunction").focus();
此处id为mnFunction
。你省略了最后的s
。你必须这样写:
$(document).ready(function(){
$("#mnRoles").blur();
$("#mnFunctions").focus(); // note that the ID has an `s` at the end
});
- 可以查看jsFiddle Demo
相关文章:
- Javascript-将变量传递给php页面,window.location.href不起作用
- 使用 Div 标签的 location.href 属性时,Eval 不起作用
- 当在 img 标签中提到类时,Href 不起作用
- 输入框上的 Href 不起作用
- JavaScript window.location.href 不起作用
- window.location.href 不起作用,无法重定向
- 幻灯片 href 不起作用
- 加载函数对 href 不起作用
- window.location.href 不起作用
- javascript document.getElementById 将 .value 更改为 .href 不起作用
- echo Javascript window.location.href 不起作用
- (jQuery)多拆分自动href不起作用
- 点击工作时 href 不起作用
- location.href不起作用
- 正在将类添加到此href.不起作用
- jQuery attr("href")不起作用
- Window.location.href '不起作用
- Jquery focus()和blur()对我的href不起作用.为什么
- Javascript更改.href不起作用
- d3js:`xlink:href`不起作用