javascript - 我将如何删除 reactJS 中当前选定的下拉行?
问题描述
我有一个选择行,在输入输入时添加数据。
<Input type="select" name="selectProf" id="selectProf">
<option>-</option>
{
thanks.map((t,i) =>
<option key={i}>{t}</option> )
}
</Input>
But when the specific option is selected I would like it to delete the specific row rather than the whole data in select.
我之前的代码是这样的:
function handleDelete(){
localStorage.setItem('profileID', '[]')
}
但这清除了数组,结果删除了选择中的所有内容。我试过这个:
function handleDelete(){
if (JSON.parse(localStorage.getItem('profileID')) === document.getElementById('selectProf').value){
//code here
}
}
但是,这种方法不起作用,因为它是不正确的。我将如何删除特定的选择行?
解决方案
推荐阅读
- javascript - 键入时 Ajax 脚本无法正常工作(keyup)
- oracle - 如何在sql server和Oracle中将列的当前值与同一列的先前值进行比较
- php - 如何在帖子列表页面中检索所有帖子的评论
- git - Fastlane 匹配无法通过 SSH 连接
- django - 如何在多对多关系中使用多项选择过滤对象
- html - Microsoft Outlook 条件格式问题
- firefox - 如何在 Firefox 中将 CSS 动画应用于 SVG 蒙版?
- logstash - jboss.logmanager 和 logstash 的自定义格式化程序
- css - `vp-preview-invisible` 类被添加到 Safari 中的预览缩略图中,但在 vimeo 嵌入视频中的 Chrome 中没有
- python - Python旋转密码脚本问题