【发布时间】:2015-12-12 04:16:34
【问题描述】:
首先,感谢您提前提供的帮助。
我试图基本上在我在页面上找到的每个锚标记上方放置一个悬停的div。所以我得到偏移量,找到每个元素的高度和宽度,然后创建一个新的 div 并将 CSS 设置为这些测量值。我在将新创建的 DIV 附加到锚标记的父级的代码时遇到问题。
$( "a" ).each(function( index ) {
tempoffset = $( this ).offset();
tempheight = $( this ).height();
tempwidth = $( this ).width();
tempoverlay = document.createElement('div');
tempoverlay.appendTo($(this).parent());
tempoverlay.setAttribute("style","background: #ccc; position: fixed; height: " + tempheight + "px; width: " + tempwidth + "px; left: " + tempoffset.left + "px; top: " + tempoffset.top + "px;");
});
我收到错误提示
tempoverlay.appendTo 不是函数 对这里可能发生的事情有什么想法吗?
【问题讨论】:
标签: javascript jquery appendto