/// <summary> /// Add or remove one or more classes to the element, depending on either the class's presence or the value of the state argument. /// </summary> public static HElement ToggleClass(this HElement element, String[] className, bool state) { if (element != null && className != null) { if (state) { element.AddClass(className); } else { element.RemoveClass(className); } } return(element); }
/// <summary> /// Add or remove one or more classes to the element, depending on either the class's presence. /// </summary> public static HElement ToggleClass(this HElement element, String[] className) { if (element != null && className != null) { foreach (var cName in className) { if (element.HasClass(cName)) { element.RemoveClass(cName); } else { element.AddClass(cName); } } } return(element); }
/// <summary> /// Remove one or more space-separated classes to be removed from the class attribute of the element /// </summary> /// <param name="element"></param> /// <param name="className"></param> /// <returns></returns> public static HElement RemoveClass(this HElement element, String className) { return(element.RemoveClass(ExtractClassNames(className))); }