54. ÔªËØÆÁÄ»¾ÓÖÐ
jQuery.fn.center = function () { this.css('position','absolute'); this.css('top', ( $(window).height() - this.height() ) / +$(window).scrollTop() + 'px'); this.css('left', ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + 'px');return this; } //Use the above function as: $('#gbin1div').center();55. ʹÓÃÌض¨Ãû×ÖµÄÔªËضÔÓ¦µÄÖµÉú³ÉÒ»¸öÊý×é
var arrInputValues = new Array(); $("input[name='table[]']").each(function(){ arrInputValues.push($(this).val()); });56. ÌÞ³ýÔªËØÖеÄHTML
(function($) { $.fn.stripHtml = function() { var regexp = /<("[^"]*"|'[^']*'|[^'">])*>/gi; this.each(function() { $(this).html( $(this).html().replace(regexp,"") ); }); return $(this); } })(jQuery); //usage: $('p').stripHtml();57. ʹÓÃclosestÀ´µÃµ½¸¸ÔªËØ
$('#searchBox').closest('div');58. ʹÓÃfirebugÀ´¼Ç¼jQueryʼþ
// Allows chainable logging // Usage: $('#someDiv').hide().log('div hidden').addClass('someClass'); jQuery.log = jQuery.fn.log = function (msg) { if (console){ console.log("%s: %o", msg, this); } return this; };59. µã»÷Á´½ÓÇ¿ÖƵ¯³öд°¿Ú
jQuery('a.popup').live('click', function(){ newwindow=window.open($(this).attr('href'),'','height=200,width=150'); if (window.focus) {newwindow.focus()} return false; });60 .µã»÷Á´½ÓÇ¿ÖÆ´ò¿ªÐ±êÇ©Ò³
jQuery('a.newTab').live('click', function(){ newwindow=window.open($(this).href); jQuery(this).target = "_blank"; return false; });61 .¼òµ¥µÄtab±êÇ©Çл»
jQuery('#meeting_tabs ul li').click(function(){ jQuery(this).addClass('tabulous_active').siblings().removeClass('tabulous_active'); jQuery('#tabs_container>.pane:eq('+jQuery(this).index()+')').show().siblings().hide(); }) <div id="meeting_tabs"> <ul> <li class="tabulous_active"><a href="#" title="">½øÐÐÖÐ</a></li> <li><a href="#" title="">δ¿ªÊ¼</a></li> <li><a href="#" title="">ÒѽáÊø</a></li> <li><a href="#" title="">È«²¿</a></li> </ul> <div id="tabs_container"> <div class="pane" >1</div> <div class="pane" >2</div> <div class="pane" >3</div> <div class="pane" >4</div> </div> </div>ÊDz»ÊǺܼò½àÄØ£¿
¡¡