i have a link in my html:
<a id="mnRoles" href="SysRoles.aspx">Roles</a>
here is more 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>
and i'm trying to set focus to it (or blur another one) through jQuery like this:
<script>
$(document).ready(function(){
$("#mnRoles").blur();
$("#mnFunction").focus();
});
</script>
but it doesn't work. any ideea why? thanks in advance!
(the reason i'm asking this: i want the focus to be set to a specific link of my choice when the page is loaded (through jQuery. i can't modify any html or css). could someone please help? thanks!)
Your link is:
<a id="mnFunctions" href="SysFunctions.aspx">Function rights</a>
Note that the id is mnFunctions
, but in your jQuery code, you wrote:
$("#mnFunction").focus();
Here, the id is mnFunction
. You omitted the s
at the end. You must write this:
$(document).ready(function(){
$("#mnRoles").blur();
$("#mnFunctions").focus(); // note that the ID has an `s` at the end
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.