如何在点击时删除(转换-翻译)元素?

时间:2018-11-08 06:26:30

标签: javascript css css3 dom

HTML:

viewDidLoad

CSS:

task

JS :(我想在单击文档中任意位置时删除圆形动画)

<div class="circle"></div>

3 个答案:

答案 0 :(得分:1)

这会将其移回原点。我认为就是你想要的。

data = base64.b64encode(db_file.read())
# Strip off the trailing newline MemoryErrorline MemoryError**
let circle = document.querySelector('.circle');
let move = true;

function comeWithMe(e) {
  let xPosition = move ? e.clientX - 10 : 0;
  let yPosition = move ? e.clientY - 10 : 0;

  circle.style.transform = `translateX(${xPosition}px) translateY(${yPosition}px)`;
}

window.onmousemove = comeWithMe;
window.onclick = function(e) {
  move = !move;
  comeWithMe(e);
}

答案 1 :(得分:1)

如果单击文档中的任意位置,这将结束动画。 onclick我正在移除mousemove事件。

let circle = document.querySelector('.circle');

function comeWithMe(e) {
  let xPosition = e.clientX - 40;
  let yPosition = e.clientY - 40;
  circle.style.transform = `translateX(${xPosition}px) translateY(${yPosition}px)`;
}
window.addEventListener("click", function(event) {
  window.removeEventListener("mousemove", comeWithMe);
});
window.addEventListener("mousemove", comeWithMe);
.circle {
  width: 30px;
  height: 30px;
  background: #fc4;
  display: block;
  border-radius: 30px;
  transform: translateX(0);
  transform-origin: center;
  transition: .1s ease-in-out;
}
<div class="circle"></div>

答案 2 :(得分:0)

您可以使用i = datetime.datetime.now() exprob = 0.80 df.loc[((df['prob'] - exprob).abs().idxmin()),'time'] + i Timestamp('2018-11-08 18:36:11.529609') setAttribute

removeAttribute

setAttribute

removeAttribute
document.getElementById('para').addEventListener('click', function() {
  document.getElementById('para').setAttribute('style', 'display:none');
});

document.getElementById('para2').addEventListener('click', function() {
  document.getElementById('para2').removeAttribute('style', 'color');
});