2024年6月14日发(作者:)
Js代码
1. // shows a given element and hides all others
2. function showViaKeypress(element_id)
3. {
4. $(".container").css("display","none");
5. $(element_id).slideDown("slow");
6. }
7. // shows proper DIV depending on link 'href'
8. function showViaLink(array)
9. {
10. (function(i)
11. {
12. $(this).click(function()
13. {
14. var target = $(this).attr("href");
15. $(".container").css("display","none");
16. $(target).slideDown("slow");
17. });
18. });
19. }
而对键盘按键的监听是用的keypress()方法,其实也没什么难度,不过我们很少在页
面上使用按键监听,这个例子比较新奇,值得我们参考,如有必要时,可以在项目里用用。
Js代码
1. $(document).keypress(function(e)
2. {
3. switch()
4. {
发布评论