美文网首页
2019-06-17

2019-06-17

作者: 多喝烫水_ | 来源:发表于2019-06-21 08:42 被阅读0次

元素绝对位置

$(function(){

var $pos = $('.pos');

//offset()是获取相对于页面左上角的绝对位置,即使外面再包一层con居中层,也不影响效果

var pos = $pos.offset();

// console.log(pos);

// alert(pos.left + "," + pos.top);

var w = $pos.outerWidth();

var h = $pos.outerHeight();

// alert(w);

$('.pop').css({left:pos.left + w,top:pos.top});

$pos.mouseover(function() {

$('.pop').show();

});

$pos.mouseout(function() {

$('.pop').hide();

});

})

jQuery循环

$(function(){

// //给全部的li设置内容和样式

// $('.list li').html('111');

// $('.list li').css({background:'gold'});

//第一个参数index是索引值

$('.list li').each(function(index) {

// alert(index);//弹出索引值

//$(this)是每一个li

$(this).html(index);

});

})

相关文章

网友评论

      本文标题:2019-06-17

      本文链接:https://www.haomeiwen.com/subject/dlseqctx.html