Is there any way to achieve this? I am using a pagination plugin that reads the number of li's inside my ul and determines the number of numbered links to spit out.
问题:
回答1:
You probably want to use .hide() and check to see if the li is visible or not.
This can be done with $("li:visible")
回答2:
See jQuery's docs:
$("#foo").remove().appendTo("#bar"); If #foo was a child of #bar, the above line doesn't have any effect. Now, storing $("#foo").remove() in a variable (it's a jQuery object) and re-appending it is left over to you as exercise ;-)
Cheers,
回答3:
There isn't any way to do it that I can think of without modifying the jQuery code. It probabl wouldn't be that hard to modify though. You would need to put in a stack (or stack like structure) and when .remove() is called, put the html in there along with the selector or something like that, and then on .undo(), put it back.
This is assuming you really need undo capabilities and not just the ability to toggle visibility with .hide()/.show() or .toggle().
回答4:
If you want a semantic undo to remove(), that will be append(). But you want probably what @contagious and @Max Schmeling suggested, a toggle().