JQuery简化常用问题

1、使用JQuery找出一组radioGroup的选中值,假设这组radio的name属性为radioGroup

$('[name=radioGroup]:checked').val()

2、实现图片等元素的放大,待放大的元素有id为animateMe

$('.animateMe').each(function(){

  $(this).animate(

    {

      width: $(this).width() * 2,

      height: $(this).height() * 2

    },

    2000

  );

});

3、实现元素的下落效果

$('.animateMe').each(function(){

  $(this)

    .css('position','relative')

    .animate(

      {

        opacity: 0,

        top: $(window).height() - $(this).height() -

             $(this).position().top

      },

      'slow',

      function(){ $(this).hide(); });

});





4、点击爆炸消失

$('#puffButton').click(function(){

          $('#testSubject').each(function(){

            var position = $(this).position();

            $(this)

              .css({position:'absolute',top:position.top,

                    left:position.left})

              .animate(

                {

                  opacity: 'hide',

                  width: $(this).width() * 5,

                  height: $(this).height() * 5,

                  top: position.top - ($(this).height() * 5 / 2),

                  left: position.left - ($(this).width() * 5 / 2)

                },

                'normal');

          });

        });

使用$(this).height() *5 /2 是为了保证scale发生的中心是图片中心,去除这两个参数,puff会从最上端和最左端发生。opacity值设置为’hide’,在完成opacity的改变之后元素会自动隐藏。如果改为’0′,虽然可以实现同样效果,但是元素框体依然会留在网页当中。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值