javascript - 有什么办法可以使用 document.getElementById 两次?
问题描述
我想在按钮槽上悬停时添加类,但是对于每个房间,槽都有相同的 id,所以 document.getElementById 不能按要求工作。有什么办法可以访问每个房间的插槽吗?我正在研究 Vue.js 在此处 输入图像描述
<w-col v-for="room in rooms" :id="room.dsid" :key="room.dsid" class="col">
<ImageTitle
:id="room.dsid"
:name="room.space_name+' '+room.building_name"
:src="room.image_url"
@infoClick="showPopOver"
></ImageTitle>
<div v-for="(n,index) in 48" :key="index" class="slot">
<w-button :id="n" raw class="slots" :class="{ 'border-top': index === 0 || index%4 === 0, 'border-bottom': index === 47}" @mouseover.native="mouseOver(n, room.dsid)" @mouseleave.native="mouseLeave()" @click="selectSlot(n, room.name)">
<w-row></w-row>
</w-button>
</div>
</w-col>
解决方案
推荐阅读
- c# - c# KeyEventArgs 与 lambda 表达式
- php - php echo 数据库行结果成卡片
- typescript - TypeScript 泛型 TypedArray:TypedArray 不可分配给 T
- javascript - 单击动态创建的 td 后,如何在 js 中创建一个 div 以填充屏幕?
- typo3 - 如何使用 extbase 插入 sys_categories
- php - 可以在 div 中显示的 jquery 和 ajax 中包含进程计数器
- python - 有效地从 numpy 矩阵中获取值
- apache-kafka - 致谢 Kafka Producer Apache Beam
- haskell - 如何在 Haskell 中本地下载 Internet 文件
- python - 通过命令行传递字典参数并在 python 脚本中访问它们