简体   繁体   English

请问,如何使用 javascript 调用 css class ? 就像在 html 中一样

[英]Can i ask, how to call css class using javascript? like in html once you call its classname it will automatically define what styles you want in div

ie. IE。 this is my class to be called in my javascript这是我的 class 要在我的 javascript 中调用

<style>
   .chzn-select{
   }

</style>



                <select class="chzn-select" id="hidden_select" name="form_select" onchange="showSelect()"> 
                <option value="">Please Select Item</option>
                <option value="">Anything</option>
                </select>

i want to call this class="chzn-select" inside javascript, like document.getElementById().style.display = "none" or anyting styles to be in here using css class i want to call this class="chzn-select" inside javascript, like document.getElementById().style.display = "none" or anyting styles to be in here using css class

<script>
   
enter code here
</script>

i want to call my class here and i dont know what will be my specific code to call my class="chzn-select";我想在这里打电话给我的 class 我不知道我的具体代码是什么来调用我的 class="chzn-select";

You can use a querySelector to select elements that have the class您可以对具有 class 的 select 元素使用 querySelector

document.querySelector(".chzn-select").style.display = "none"; document.querySelector(".chzn-select").style.display = "none";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM