jquery常用的一些代码

//行高亮
    $("tr").mouseover(function(){  
        $(this).addClass("over");  
    }).mouseout(function(){  
        $(this).removeClass("over");  
    }) 
//隔行变色
    $(".tablesorter tbody tr:even").addClass("even");
    $(".tablesorter tbody tr:odd").addClass("odd");
//跳转
window.location.href="url"
//iframe内容
document.getElementById("if").contentWindow.document.getElementById("page_imageuids").value;


//iframe父
  jQuery(window.parent.document).find("#windownbg").remove();
  window.parent.location.reload();
//open()父
window.opener.location.reload();
//居中
var wnd = $(window),
    doc = $(document),
    pTop = doc.scrollTop(), 
    pLeft = doc.scrollLeft();
pTop += (wnd.height() - jQuery("#div").height()) / 2;
pLeft += (wnd.width() - jQuery("#div").width()) / 2;
jQuery("#div").css({top: pTop, left: pLeft});
//拖动
    jQuery('#x').mousedown(function(event){
     var obj= jQuery(this);
     var ox = obj.position().left;
     var oy = obj.position().top;
     var mx = event.clientX;
     var my = event.clientY;
     var width = obj.width();
     var height = obj.height();
     $(document).mousemove(function(event){      
      if (window.getSelection) {
       window.getSelection().removeAllRanges();
      } else {
             document.selection.empty();
            }
      var left = Math.max(ox+event.clientX-mx, 0);
      var top = Math.max(oy+event.clientY-my, 0);
      obj.css({left: left, top: top});
     }).mouseup(function(){
            $(document).unbind('mousemove');
            $(document).unbind('mouseup');
     });
    }); 

//获取body高
   if ($.browser.msie && $.browser.version < 7) {
    var scrollHeight = Math.max(
     document.documentElement.scrollHeight,
     document.body.scrollHeight
    );
    var offsetHeight = Math.max(
     document.documentElement.offsetHeight,
     document.body.offsetHeight
    );
    
    if (scrollHeight < offsetHeight) {
     return $(window).height();
    } else {
     return scrollHeight;
    }
   } else {
    return $(document).height();
   }

//获取body宽
   if ($.browser.msie && $.browser.version < 7) {
    var scrollWidth = Math.max(
     document.documentElement.scrollWidth,
     document.body.scrollWidth
    );
    var offsetWidth = Math.max(
     document.documentElement.offsetWidth,
     document.body.offsetWidth
    );
    
    if (scrollWidth < offsetWidth) {
     return $(window).width();
    } else {
     return scrollWidth;
    }
   } else {
    return $(document).width();
   }

 

jQuery tab选项卡

  $("a.tab").click(function () {
   $(".active").removeClass("active");
   $(this).addClass("active");
   $(".content").hide();
   $("#"+$(this).attr("title")).fadeIn();
   
  });

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值