×ðÁú¿­Ê±¹ÙÍøµÇ¼

jsÖÐÔõÑùÈ¥µôcssÃûÌÃ

ʹÓà classlist.remove() ÒªÁì¿É´ÓÔªËØÒƳý css Ñùʽ£ºÑ¡ÔñÄ¿µÄÔªËØ¡£»ñÈ¡ÔªËصÄÑùʽÀàÁбí¡£Ê¹Óà remove() ÒªÁì´Ó classlist ÖÐÒƳýËùÐèµÄÑùʽÃû³Æ¡£

ÔõÑùÔÚ JavaScript ÖÐÒƳý CSS Ñùʽ

ÔÚ JavaScript ÖУ¬¿ÉÒÔʹÓà classList.remove() ÒªÁìÀ´ÒƳý HTML ÔªËØÉ쵀 CSS Ñùʽ¡£ÒÔÏÂÊÇ°ì·¨£º

Ñ¡ÔñÔªËØ£ºÊ¹Óà document.querySelector() »ò document.getElementById() Ñ¡ÔñÄ¿µÄÔªËØ¡£

»ñÈ¡ classList£ºÊ¹Óà classList ÊôÐÔ»ñÈ¡ÔªËصÄÑùʽÀàÁбí¡£

ÒƳýÑùʽ£ºÊ¹Óà remove() ÒªÁì´Ó classList ÖÐÒƳýËùÐèµÄ CSS ÑùʽÃû³Æ¡£

// Ñ¡ÔñÔªËØ
const element = document.querySelector('div');

// »ñÈ¡ classList
const classList = element.classList;

// ÒƳýÑùʽ
classList.remove('my-class');

µÇ¼ºó¸´ÖÆ

ʾÀý£º

ÒÔÏÂʾÀýÏÔʾÔõÑùʹÓà classList.remove() ÒªÁì´Ó¾ßÓÐ my-class ÑùʽµÄÔªËØÖÐÒƳý¸ÃÑùʽ£º

Á¬Ã¦Ñ§Ï°¡°Ç°¶ËÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

<div class="my-class">Hello World</div>

µÇ¼ºó¸´ÖÆ

const element = document.querySelector('div');
element.classList.remove('my-class');

µÇ¼ºó¸´ÖÆ

Ö´Ðд˴úÂëºó£¬ÔªËؽ«²»ÔÙ¾ßÓÐ my-class Ñùʽ¡£

ÒÔÉϾÍÊÇjsÖÐÔõÑùÈ¥µôcssÃûÌõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ