我想从一个新的弹出窗口中通过事件点击一个新的弹出窗口中的元素获得价值.我的代码在我点击按钮后第一次工作.在我重新载入新的弹出窗口页面后,我的代码不工作.
Index.html
<button id="open-new-windows">TEST</button>
<script>
$("#open-new-windows").click(function () {
var w = window.open(
"http://localhost/test/child.html",
"TEST",
"width=300,height=400"
);
w.addEventListener("load", function () {
var html = $(w.document.body).find("ul");
console.log(html.length); // return 1
html.on("click", "li", function () {
var a = $(this).text();
alert(a);
});
});
});
</script>
Child.html
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
</ul>
我想在页面再次加载后获得一个值.请帮帮我.谢谢.