0
我写功能,输出顶部和左侧DIV ID内的所有DIV值=容器我怎样才能在%相对DIV
var main = $('#container'),
res = $('#result'),
bw = parseInt(main.css('border-left-width'), 10),
mT = main.offset().top + bw,
mL = main.offset().left + bw;
$('#btn1').on('click', function() {
var allCoords = $('div', main).map(function() {
return getCoords(this);
}).get().join('<br>');
res.html(allCoords); });
function getCoords(el) {
var $that = $(el),
pos = $that.offset(),
posTop = pos.top - mT,
posLeft = pos.left - mL;
var pos = el.id + ' top: ' + posTop + 'px; left: ' + posLeft + 'px;';
return pos;}
我怎样才能在%相对DIV值(左上) ID容器 请帮助me.Thank
非常感谢! – ZKolya 2015-04-01 21:33:54
请给我投票:) – 2015-04-03 07:56:51