获取元素坐标和窗口大小

(1)获取元素坐标

var $self=$(imgSelf);
        var offset2=$self.offset();
        var left=Number(offset2.left)+20;

(2)获取窗口大小

//Cross browser gets the size of Visual area window,Have nothing to do with scroll bars
var getInner=(function() {
	// alert(typeof window.innerWidth !== 'undefined');
	if (typeof window.innerWidth !== 'undefined') {//Notice:'undefined' is right
		return function(){
			return {
				width : window.innerWidth,
				height : window.innerHeight
			}
		}
	} else {
		return function(){
			return {
				width : document.documentElement.clientWidth,
				height : document.documentElement.clientHeight
			}
		}
	}
})();

var delta=left+50-getInner().width;

(3)动态增加节点

在后面增加兄弟节点

  $next.after('<div id="answer_'+id+'"  ></div>');

增加子节点:

$('body div.draft').append(html);
扫描二维码关注公众号,回复: 526274 查看本文章

猜你喜欢

转载自hw1287789687.iteye.com/blog/2267320