html - Change CSS attribute with TypeScript and Angular
问题描述
I want to change the z-index
CSS attribute from the <footer>
when <select>
is open, but i don't know how to do it on TypeScript (Angular 10). The footer already have z-index: 9998;
but i want to set it to 0;
. The reason is because when my select is open, the options go under the footer and the user can't really choose.
$('.test').on('click', () => {
$('footer').css('z-index', '0');
})
<select
class="test"
placeholder="select an option"
formControlname="bank">
<option> 1 </option>
<option> 2 </option>
<option> 3 </option>
<option> 4 </option>
</select>
解决方案
There you go, it works just fine as soon as you click the select. The footer z-index is set to 0. Make sure you are importing jquery in your code.
$('.test').on('click', () => {
$('footer').css('z-index', '0');
})
footer {
z-index: 9998;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select class="test" placeholder="select an option" formControlname="bank">
<option> 1 </option>
<option> 2 </option>
<option> 3 </option>
<option> 4 </option>
</select>
<footer>footer</footer>
推荐阅读
- c++ - 如果从 QRunnable 或其他线程调用 Qt 信号和槽将不起作用
- typescript - Typescript 具有共享类型的多个对象属性
- html - 如何设置已经“嵌入”到 HTML 中的标签的“目标”属性?
- python-3.x - jupyter lab 中的 Bqplot 返回字符串而不是(交互式)图像
- django - 在 Django View to template 中,我的日期总是以缩写月份、DD、yyyy 的形式出现,但 datepicker 会生成 MM/DD/YYYY
- vim - 有没有办法使用带有寄存器的动作?
- notifications - 在托管的 Azure Devops 环境中,是否可以为未提供开箱即用的字段创建通知?
- android - 在视图底部添加阴影
- oop - 类成员变量不是和全局变量一样糟糕吗?
- c# - C#中的双重泛型类型