我有这行HTML代码:
<div id="slideshow2">
<div class="active2">
<img src="noangel.png" alt="Slideshow Image 1" />
<p class="imgDescription2">NoAngel</p>
</div>
<div>
<img src="anders.png" alt="Slideshow Image 2" />
<p class="imgDescription2">This is Anders</p>
</div>
<div>
<img src="fayeblais.png" alt="Slideshow Image 3" />
<p class="imgDescription2">Something about FayeBlais</p>
</div>
<div>
<img src="ronny.png" alt="Slideshow Image 4" />
<p class="imgDescription2">Ronny Information</p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我如何仅针对第一段或第三段仅更改颜色,字体类型等?
我有一个状态,其中包含默认分配为 false 或 true 的项目和复选框列表(取决于我正在使用的 API)。
为了简单起见,我们假设我的状态是这样的。
state = {
list: [
{
id: 0,
name: 'item1'
assigned: true
}
],
dirtyList: []
}
Run Code Online (Sandbox Code Playgroud)
单击复选框时,您按下一个按钮,弹出窗口会告诉您该项目是否已注册或删除(复选框为真/假)。但是,假设您在已选中复选框的情况下启动页面,然后单击它两次(使其再次选中为真),弹出窗口不应显示该项目已注册,因为原始状态尚未更改。(它从true
,出发false
,然后返回true
)
这是我的复选框handleChange函数
checkboxChanged = (event, id) => {
let isChecked = event.target.checked
const index = this.state.list.findIndex(list => list.id === id)
const newState = [...this.state.list]
let newList = { ...newState[index] }
console.log(newList)
// By console logging this, it eventually tells me the previous state of the item that was clicked
newState[index].assigned …
Run Code Online (Sandbox Code Playgroud)