#3825 closed enhancement (fixed)
enhance .toggleClass
Reported by: | cloudream | Owned by: | brandon |
---|---|---|---|
Priority: | minor | Milestone: | 1.4 |
Component: | core | Version: | 1.2.6 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
- remove/re-add all original CSS class
implement: save original class to $.data on elements
Case: el: <span class="a b" />
step#1:$(el).toggleClass(); -save "a b" to $.data(this,"originalClass"), then remove "a b" class on this element. step#2:$(el).toggleClass(); -restore $.data(this,"originalClass")(if exists) to this element.
And with boolean: step#1:$(el).toggleClass(false); -save "a b" to $.data(this,"originalClass"), then remove "a b" class on this element.
step#1:$(el).toggleClass(true); -restore $.data(this,"originalClass")(if exists) to this element.
2.handle multi-class without boolean. use .toggleClass("c b") instead of .toggleClass("c").toggleClass("b")
implement: split className string before pass it to $.className[add/ remove], and handle each one separately
Case: el: <span class="a b" />
step#1:$(el).toggleClass("b c"); -remove class "b" and add class "c" on this element. step#2:$(el).toggleClass("b c"); -remove class "c" and add class "b" on this element.
Attachments (1)
Change History (5)
Changed 14 years ago by
Attachment: | toggleClass.diff added |
---|
comment:1 Changed 14 years ago by
Owner: | set to brandon |
---|
comment:2 Changed 14 years ago by
Milestone: | 1.3 → 1.3.3 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Added in r6332.
comment:3 Changed 12 years ago by
Keywords: | needsDocs added |
---|
comment:4 Changed 11 years ago by
Keywords: | needsDocs removed |
---|
added documentation at http://api.jquery.com/toggleClass/
unit test and core implementation proposal for #3825 enhancement (forgot one cleanup)