the first object selected is not being recognized, but the remainder are
$(links).next(date).next(breakline).andSelf().wrapAll('<span class="mangaLine">开发者_Python百科;');
You need to include the previous object in the chain as well with another .andSelf()
call, like this:
$(links).next(date).andSelf() //add links back
.next(breakline).andSelf() //add dates and links back
.wrapAll('<span class="mangaLine">');
.andSelf()
only adds the .prevObject
in the chain, it can't hop back more than one step, so you need to get the chain before as well. There are a few work-arounds with chaining, I just did that I thought looked cleanest above.
I'm not quite sure I understand what you want, and it may depend on your exact HTML structure and sectors, but I think you need to add an additional andSelf()
after the first next
:
$(links).next(date).andSelf().next(breakline).andSelf().wrapAll('<span class="mangaLine">');
精彩评论