Indenting/breaking jquery chains for readability [closed]
I'm curious as to how other people indent/break long jQuery chains, as I can never decide what is more readable (particularly when using .end() to "close" a block of methods e.g.
$(this).not(":has(.pointer)").append(pointerHtml)
.end()
.closest("li").toggleClass("selected")
.siblings().removeClass("selected")
.andSelf().removeClass("pre-selected")
开发者_开发技巧 .end().end()
.filter(".selected").prev().addClass("pre-selected");
How would YOU format this?
$(this).not(":has(.pointer)")
.append(pointerHtml)
.end()
.closest("li")
.toggleClass("selected")
.siblings()
.removeClass("selected")
.andSelf()
.removeClass("pre-selected")
.end()
.end()
.filter(".selected")
.prev()
.addClass("pre-selected");
精彩评论