[英]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.