Skip to content

.replaceClass()

.replaceClass( oldClassName, newClassName)

将匹配集合中的元素旧的类名替换成新的类名。

NOTE

该方法不存在于jQuery的api中,是domtify中独有的方法,根据jQuery的api设计风格以及replaceAPI设计而来。

.replaceClass( oldClassName, newClassName) from @1.0

  • oldClassName
    • 类型: String
    • 描述: 要被替换的旧的类名
  • newClassName
    • 类型: String | Function( Integer index, String currentClassName ) => String
    • 描述: 要替换的类名,如果是函数,该函数接收集合中元素的索引位置和现有类名作为参数。在函数内部,this引用集合中的当前元素

.replaceClass( classNames) from @1.0

  • classNames
    • 类型: PlainObject
    • 描述: 可以通过传入对象方式批量替换,key代表oldClassName,value代表newClassName

.replaceClass( classNames) from @1.0

  • classNames
    • 类型: Function( Integer index, String currentClassName ) => PlainObject
    • 描述: 该函数接收集合中元素的索引位置和现有类名作为参数。在函数内部,this引用集合中的当前元素,返回一个keyoldClassNamevaluenewClassName的对象。

基于 MIT 许可发布