[英]How to give !important in javascript
I am hiding one div and showing another. 我要隐藏一个div并显示另一个。 But I can't hide first div when the second is block.
但是当第二个是block时,我无法隐藏第一个div。 I think that's because first is bootstrap and need to overwrite to display with
!important
to run display: none;
我认为这是因为首先是引导程序,需要覆盖才能显示
!important
以运行display: none;
correctly. 正确。 But how can I use the it in Javascript.
但是如何在Javascript中使用它。
function switchVisible() {
if (document.getElementById('main-card')) {
if (document.getElementById('main-card').style.display == 'none') {
document.getElementById('main-card').style.display = 'block';
document.getElementById('map').style.display = 'none';
}
else {
document.getElementById('main-card').style.display = 'none';
document.getElementById('map').style.display = 'block';
}
}
}
I tried 'none !important' but that doesn't work. 我尝试了“无重要!”,但这不起作用。
How about using Jquery much more simple. 如何使用Jquery更简单。 And it'll fix your problem.
它将解决您的问题。
$('body').on("click touchstart", "#Button1", function(e){
$("#main-card, #map").toggle();
});
you can use inline css style by jquery: 您可以通过jquery使用内联CSS样式:
$('body').on("click touchstart", "#Button1", function(e){
$("#main-card).css("display","none");
});
inline css is nearly !import 内联CSS几乎是!import
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.