×

jquery的键盘事件修改代码

作者:ceshi2018.01.03来源:Web前端之家浏览:9044评论:0
关键词:JQueryJS

jquery的键盘事件修改代码。

  1. (function($){ 
  2. var no_ie_pr=function(e){ 
  3. var _this=e; 
  4. var tabpr=function(e){ 
  5. _this.attr('tabIndex', 1).click(function(){ 
  6. _this.focus(); 
  7. }); 
  8. if(!$.browser.msie){ 
  9. _this.css("outline-style", "none"); 
  10. } 
  11. } 
  12. var gettag=_this[0].tagName.toLowerCase(); 
  13. var
  14.  
  15. oe=['abbr','acronym','address','b','bdo','big','blockquote','center','cite','dd','del','dir','dfn','dl','dt','em','font','form','h1','h2','h3','h4','h5','h6','i','ins','img','ins','kbd','li','menu','ol','p','pre','q','s','samp','small','strike','strong','sub','sup','th','tr','tt','u','ul','var']; 
  16. if($.inArray(gettag,oe)!=-1){ 
  17. tabpr(); 
  18. }else{ 
  19. if ($.browser.msie) { 
  20. var ce=['span','div']; 
  21. if($.inArray(gettag,ce)!=-1){ 
  22. //IE只对绝对定位元素和固定定位元素有效,加tabIndex无法消除虚线 
  23. }else{ 
  24. var ce=['label','legend','tbody','tfoot','thead']; 
  25. if($.inArray(gettag,ce)!=-1){ 
  26. tabpr(); 
  27. } 
  28. } 
  29. }else{ 
  30. var ce=['caption','fieldset','table','td','code','div','span','label','legend','tbody','tfoot','thead']; 
  31. if($.inArray(gettag,ce)!=-1){ 
  32. tabpr(); 
  33. } 
  34. } 
  35. } 
  36. } 
  37.  
  38. $.fn.oldKeyup=$.fn.keyup; 
  39. $.fn.keyup=function(fn){ 
  40. no_ie_pr(this); 
  41. $(this).oldKeyup(fn); 
  42. } 
  43.  
  44. $.fn.oldKeypress=$.fn.keypress; 
  45. $.fn.keypress=function(fn){ 
  46. no_ie_pr(this); 
  47. $(this).oldKeypress(fn); 
  48. } 
  49.  
  50. $.fn.oldKeydown=$.fn.keydown; 
  51. $.fn.keydown=function(fn){ 
  52. no_ie_pr(this); 
  53. $(this).oldKeydown(fn); 
  54. } 
  55.  
  56. })(jQuery)

您的支持是我们创作的动力!
温馨提示:本文作者系 ,经Web前端之家编辑修改或补充,转载请注明出处和本文链接:
https://jiangweishan.com/article/svg1488124800974.html

网友评论文明上网理性发言 已有0人参与

发表评论: