1、13. );14. 3. 在新窗口中打开链接view plaincopy to clipboardprint?2. /Example 1: Every link will open in a new window 3. $(ahref=http:/).attr(target, _blank4. 5. /Example 2: Links with the rel=external attribute will only open in a new window 6. $(arel$=external).click(function() 7. this.target = ;8. );9. );10
2、. / how to use 11. open link4. 检测浏览器注: 在版本jQuery 1.4中,$.support 替换掉了$.browser 变量。2. / Target Firefox 2 and above 3. if ($.browser.mozilla & $.browser.version = 1.8 ) 4. / do something 5. 6. 7. / Target Safari 8. if( $.browser.safari ) 9. / do something 10. 11. 12. / Target Chrome 13. if( $.browser.c
3、hrome) 14. / do something 15. 16. 17. / Target Camino 18. if( $.browser.camino) 19. / do something 20. 21. 22. / Target Opera 23. if( $.browser.opera) 24. / do something 25. 26. 27. / Target IE6 and below 28. if ($.browser.msie & $.browser.version = 6 ) 29. / do something 30. 31. 32. / Target anythi
4、ng above IE6 33. if ($.browser.msie & 6) 34. / do something 35. 36. );5. 预加载图片2. jQuery.preloadImages = function() 3. 4. for(var i = 0; isrc, argumentsi);6. ;7. / how to use 8. $.preloadImages(image1.jpg6. 页面样式切换a.Styleswitcher).click(function() 3. /swicth the LINK REL attribute with the value in A
5、REL attribute 4. $(linkrel=stylesheet).attr(href , $(this).attr(rel6. / how to use 7. / place this in your header 8. 9. / the links 10. Default ThemeRed Theme12. Blue Theme tallest) 7. tallest = thisHeight;8. 10. group.height(tallest);11. 12. / how to use 13. $(document).ready(function() 14. equalHe
6、ight($(.left15. equalHeight($(.right16. );17. );8. 动态控制页面字体大小用户可以改变页面字体大小2. / Reset the font size(back to default) 3. var originalFontSize = $(html).css(font-size4. $(.resetFont5. $(, originalFontSize);6. );7. / Increase the font size(bigger font0 8. $(.increaseFont9. var currentFontSize = $(10. var
7、 currentFontSizeNum = parseFloat(currentFontSize, 10);11. var newFontSize = currentFontSizeNum*1.2;12. $(, newFontSize);13. return false;14. );15. / Decrease the font size(smaller font) 16. $(.decreaseFont17. var currentFontSize = $(18. var currentFontSizeNum = parseFloat(currentFontSize, 10);19. va
8、r newFontSize = currentFontSizeNum*0.8;20. $(21. return false;22. );23. );9. 返回页面顶部功能2. $(ahref*=#3. if (location.pathname.replace(/,) = this.pathname.replace(/,) 4. & location.hostname = this.hostname) 5. var $target = $(this.hash);6. $target = $target.length & $target 7. | $(name= + this.hash.slic
9、e(1) +8. if ($target.length) 9. var targetOffset = $target.offset().top;10. $(html,body11. .animate(scrollTop: targetOffset, 900);12. return false;13. 15. );16. / how to use 17. / place this where you want to scroll to 18. 19. / the link 20. go to top21. );11.获得鼠标指针值2. $().mousemove(function(e) 3. /
10、display the x and y axis values inside the div with the id XY #XY).html(X Axis : + e.pageX + | Y Axis + e.pageY);7. /DIV8. 12. 验证元素是否为空2. if ($(#id).html() 3. / do something 4. 13. 替换元素).replaceWith(3. I have been replaced5. 14. jQuery延时加载功能view plaincopy to clipboardprint?2. window.setTimeout(funct
11、ion() 4. , 1000);15. 移除单词功能view plaincopy to clipboardprint?2. var el = $(3. el.html(el.html().replace(/word/ig, 16. 验证元素是否存在于对象集合中view plaincopy to clipboardprint?).length) 17. 使整个可点击view plaincopy to clipboardprint?div3. /get the url from href attribute and launch the url 4. window.location=$(this
12、).find(ahref return false;index.htmlhome 1200 ) body).addClass(large6. else 7. $().removeClass(9. 10. $(window).resize(checkWindowSize);11. );19. 克隆对象view plaincopy to clipboardprint?2. var cloned = $().clone();3. / how to use 4. 20. 使元素居屏幕中间位置view plaincopy to clipboardprint?2. jQuery.fn.center = f
13、unction () 3. this.css(position,absolute4. this.css(top, ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + px5. this.css(left, ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + 6. return this;7. #id).center();21. 写自己的选择器view plaincopy to clipboardprint?2. $.extend($.
14、expr:, 3. moreThen1000px: function(a) 4. return $(a).width() 1000;.box:moreThen1000px8. / creating a simple js alert box 9. alert(The element that you have clicked is over 1000 pixels wide22. 统计元素个数view plaincopy to clipboardprint?p).size();3. );23. 使用自己的 Bulletsview plaincopy to clipboardprint?ul).
15、addClass(Replaced3. $(ul li).prepend( 4. / how to use 5. ul.Replaced list-style : none;24. 引用Google主机上的Jquery类库Let Google host the jQuery script for you. This can be done in 2 ways.1. /Example 1 2. 4. google.load(jquery1.2.65. google.setOnLoadCallback(function() 6. / do something 7. );/SCRIPT type=text/javascript9. 10. / Example 2:(the best and fastest way) 25. 禁用Jquery(动画)效果2. jQuery.fx.off = true;26. 与其他Javascript类库冲突解决方案view plaincopy to clipboardprint?2. var $jq = jQuery.noConflict();3. $jq().show();英文地址:
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1