UNPKG

@ivujs/i-utils

Version:

前端模块化 JavaScript 工具库

61 lines (60 loc) 1.9 kB
/** * @module 浏览器Dom */ /** * 判断元素包含某个类名 * @param {HTMLElement} elem 元素 * @param {string} className 类名 * @return {boolean} 返回true和false */ export declare function hasClass(elem: HTMLElement, className: string): boolean; /** * 元素添加类名 * @param {HTMLElement} elem 元素 * @param {string} className 类名 */ export declare function addClass(elem: HTMLElement, className: string): void; /** * 元素删除类名 * @param {HTMLElement} elem 元素 * @param {string} className 类名 */ export declare function removeClass(elem: HTMLElement, className: string): void; /** * 元素替换类名 * @param {HTMLElement} elem 元素 * @param {string} newClassName 新的类名 * @param {string} oldClassName 被替换掉的旧类名 */ export declare function replaceClass(elem: HTMLElement, newClassName: string, oldClassName: string): void; /** * 添加元素的style样式 * @param {HTMLElement} elem 元素 * @param {Object} styles 样式属性集合 */ export declare function addStyle(elem: HTMLElement, styles?: Record<string, string>): void; /** * 获取元素的style样式 * @param {HTMLElement} elem 元素 * @param {string} name 属性 * @returns {string|undefined} 返回样式的值 */ export declare function getStyle(elem: HTMLElement, name: string): string | unknown; /** * 删除元素的style样式 * @param {HTMLElement} elem 元素 * @param {string} name 属性 */ export declare function removeStyle(elem: HTMLElement, name: string): void; /** * html标签转义 * @param {string} htmlStr html字符串 * @returns {string} 返回转义后的字符串 */ export declare function htmlEncode(htmlStr: string): string; /** * html标签解码 * @param {string} htmlStr html字符串 * @returns {string} 返回解析后的字符串 */ export declare function htmlDecode(htmlStr: string): string;