我在加載新元素在div中後顯示工具提示有問題。加載新的html內容後工具提示不起作用
我的內容加載代碼:
$ (Function() {
$ ('. Prop-next'). Click (function() {
$ ('.props') .html ('<img src = "/ images/loading.gif" class = "loading" />')
var p = parseInt ($ (this) .attr ('p')) + 3;
$ (this) .attr ('p', p);
$ .post ('/ lib/props.php', {p: p}, function (item) {
$ ('. Props'). Html (item);
});
});
});
調用div中.prop,接下來點擊元素時
.props新的內容出現,而腳本不起作用:
提示代碼:
var tooltips = document.querySelectorAll ('.tooltip');
window.onmousemove = function (e) {
var x = (e.clientX - 350) + 'px',
y = (e.clientY + 50) + 'px';
for (var i = 0; i <tooltips.length; i ++) {
tooltips [i] .style.top = y;
tooltips [i] .style.left = x;
}
};
在您的查詢選擇器和網址中存在多個空格('')字符使這個腳本無法工作 – 3Dos
空格w ^在代碼在編輯器中輸入時創建。我向你保證代碼中沒有空格 – urbmake