我有這樣一行:jQuery的偏移left屬性不工作
$("#"+genId).css({"border":"2px solid black", "background-color":"white", "position":"fixed", "z-index": "10000000000", "top": (pos.top + h + 10)},"left", pos.left + w + 10);
當我在最後去掉左邊它的工作原理,但是當我添加的左半部分的元素消失。
不知道發生了什麼事:
全功能:
function showPopUp(element){
var pos = element.offset();
var h = element.height();
var w = element.width();
var newDiv = document.createElement('div');
var genId = ("a" + (new Date).getTime() + Math.floor(Math.random() * 20));
newDiv.id = genId;
document.getElementsByTagName('body')[0].appendChild(newDiv);
$("#"+genId).css({"border":"2px solid black", "background-color":"white", "position":"fixed", "z-index": "10000000000", "top": (pos.top + h + 10), "left": (pos.left + w + 10)});
$("#"+genId).append("<p> Tag:" + element.prop("tagName") + " || Em: "+ getEm(element) + "em || Px: " + getPixel(element) + "</p><p>Font Family: " + getFontFam(element) + "</p>");
}
編輯
代碼固定錯字從文件複製
... "top": (pos.top + h + 10), "left": (pos.left + w + 10)});
嗨,你仍然對答案感興趣嗎? – Ionut