91-9990449935 0120-4256464 |
jQuery detach()The jQuery detach() method is used to remove the selected elements, including all texts and child nodes and keeps only data and events. This method saves a copy of the removed elements to reinsert them whenever they needed later. There are some other methods also which are used to remove elements e.g. jQuery remove() method, jQuery empty() method etc. But there is a little difference among them. jQuery remove() method: This method is used to remove the elements as well as its data and events. jQuery empty() method: This method is used to remove only the content from the selected elements. Syntax: Example of jQuery detach() methodLet's take an example to demonstrate the effect of jQuery detach() method. Test it NowjQuery detach() example 2Test it NowDifference between detach() and remove() methodLet's take an example to clear the difference between detach() and remove() method: jQuery detach() example 3Test it NowBy the above example, it is clear that jQuery detach() method doesn't remove inner data and events. In the above example, the click event is remained safe even after the detach() method is applied.
Next TopicjQuery scrollTop()
|