简体   繁体   English

display:none 和 visibility:hidden 都不起作用

[英]Both display:none and visibility:hidden not working

I cannot figure out why this is not working, so please help me figure it out.我无法弄清楚为什么这不起作用,所以请帮我弄清楚。

Display.js:显示.js:

render(){
    const notesList = this.props.notesList;
    const displayNotes = notesList.map( (note,note_id) =>
      <div className="display">
        <p id={'note-' + note_id}>{note}</p>
        <button type="button" className="edit-button" onClick={()=>this.props.edit(note_id)}>Edit</button>
        <button type="button" className="delete-button" onClick={()=>this.props.delete(note_id)}>Delete</button>
      </div> );

    return <div>{displayNotes}</div>;
  }
}

App.js:应用程序.js:

  handleEdit = (note_id) => {
    const id = 'note-' + note_id;
    document.getElementById(id).contentEditable = 'true';
  }

  handleDelete = (note_id) => {
    const id = 'note-' + note_id;
    document.getElementById(id).display = 'none';
  }

When you want to change an element css property, you need to access the style object first.当您想要更改元素 css 属性时,您需要先访问样式 object。

This is how you would get it:这就是你得到它的方式:

  handleDelete = (note_id) => {
    const id = 'note-' + note_id;
    document.getElementById(id).style.display = 'none';
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么Google跟踪代码管理器会同时显示:无和可见性:隐藏在iframe上? - Why Google Tag Manager puts both display:none AND visibility:hidden on iframe? 使用可见性:隐藏和显示:CSS中没有? - Using visibility: hidden and display: none together in CSS? 可见性:隐藏和显示之间的性能差异:无 - Performance differences between visibility:hidden and display:none 隐藏大元素而不使用display:none或visible:hidden - Hide a large element without using display:none or visibility:hidden 如果未启用JavaScript,则显示后备广告:无/可见性:隐藏 - Fallback for display:none / visibility:hidden in case javascript is disabled 隐藏元素而不使用 display:none 或 visibility:hidden - Hiding an element without using display:none or visibility:hidden 可见性:隐藏在IE中无法正常工作 - visibility: hidden in IE not working 隐藏的可见性在safari中不起作用 - visibility hidden is not working in safari “可见性:隐藏;” 不适用于 TCPDF - "visibility:hidden;" is not working with TCPDF 避免隐藏的元素占用空间/无法使visible:true最初显示为:css样式中没有 - avoid hidden element occupying space/not possible to make visibility:true which is initially made display:none in css style
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM