Loading...

javascript change css class

Temperature: 0 °C

Mark ChangMark Chang
author_tools


javascript change css class
使用classList是一個方便的替代方法,可以將元素的類列表作為空格分隔的字符串來訪問。

document.getElementById("MyElement").classList.add('MyClass');
document.getElementById("MyElement").classList.remove('MyClass');
if ( document.getElementById("MyElement").classList.contains('MyClass') )
document.getElementById("MyElement").classList.toggle('MyClass');

不幸的是,這些在Internet Explorer v10之前的版本中不起作用。

但我想這些應該都是已經是不變的事實~所以也不意外了。

Internet Explorer 永遠都是工程師的惡夢( ̄∇ ̄)

https://innstory.com/story-javascript_change_css_class-1842
javascript

Prev
 fancybox_close的方式

Next
嘰嘰喳喳 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

.htaccess與RewriteEngine一起使用時500內部服務器錯誤

.htaccess與Rewr...

在某些情況下,可能未加載apache中的modrewrite模塊。 這時只需要執行以下指令就可以獲得...

ubuntu 18.04  apache 目錄啟用並開啟.htaccess 覆寫

ubuntu 18.04 ...

.htaccess是在Apache HTTP Server這款服務器架設軟件下的一個對於系統目錄進行...

PHP查詢陣列中是否存在特定字串in_array() 函數

PHP查詢陣列中是否存在特定...

使用函數inarray() ,適用版本(PHP , PHP 5, PHP , PHP ) 使用方式:...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format