例如要为div上的某个按钮,添加监听事件
var btn = document.getElementById("myBtn"); btn.addEventListener("click", function () { alert(this.id); }, false);
>>Cesium的timeline监听事件如何移除:http://blog.sina.com.cn/s/blog_15e866bbe0102yysg.html
要移除,首先要有timeline:
createTimeLine() {if (!window.viewer.timeline) { // Timeline var timelineContainer = document.createElement('div'); timelineContainer.className = 'cesium-viewer-timelineContainer'; timelineContainer.style.right = '0px'; viewerContainer.appendChild(timelineContainer); var timeline = new Cesium.Timeline(timelineContainer, window.viewer.clock); timeline.addEventListener('settime', this.onTimelineScrubfunction, false); timeline.zoomTo(window.viewer.clock.startTime, window.viewer.clock.stopTime); this.timeline = timeline; } },
方法二: