[英]Javascript clicks suddenly completely stopped working
I have been working on a project and have iterations of it (ensuring that each worked with its intended functionality before moving on).我一直在研究一个项目并对其进行了迭代(确保每个项目在继续之前都使用其预期的功能)。
As I went to start working today, a key part of my functionality has stopped working;当我今天开始工作时,我的功能的一个关键部分已经停止工作; even worse, opening up previous iterations (which have NOT been modified) also do not work for this feature.
更糟糕的是,打开以前的迭代(尚未修改)也不适用于此功能。
I have not edited the code whatsoever.我没有编辑任何代码。
The relevant code is here:相关代码在这里:
window.onload = function(){ // test for clicks on list
var ul = document.getElementById("list");
ul.onclick = function(event){
var target = getEventTarget(event);
//do stuff
}
}
and the function getEventTarget和函数 getEventTarget
function getEventTarget(e){
e = e || window.event;
return e.target || e.srcElement;
}
It is not doing anything with the click event (not producing any console logs).它没有对点击事件做任何事情(不产生任何控制台日志)。 As I reiterate, it was working perfectly fine prior to now.
正如我重申的那样,它在此之前运行良好。
I have restarted my computer, completely cleared the browsers history (Chrome), tried the code on another computer (which it also was previously working on, to no avail), and tried different browsers.我重新启动了我的计算机,完全清除了浏览器历史记录(Chrome),在另一台计算机上尝试了该代码(它以前也在使用,但无济于事),并尝试了不同的浏览器。
What do I do?我该怎么办?
EDIT:编辑:
HTML: HTML:
<div class="mylist hidden">
<div class="container">
<div id="addplaylist"><a><span class="glyphicon glyphicon-adjust"></span>
<span>Here's my List</span>
</a></div>
<br />
<ul id="list">
</ul>
</div>
</div>
You have to add atleast a single text inside ul tag.您必须在 ul 标签内添加至少一个文本。 Then only you will be able to click it.
然后只有您才能单击它。
window.addEventListener('load', function() {
document.getElementById("list").addEventListener('click', function(event) {
var target = getEventTarget(event);
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.