Bug Tracker

Modify

Ticket #11019 (closed bug: invalid)

Opened 2 years ago

Last modified 2 years ago

.empty() on an empty elment deletes siblings.

Reported by: John@… Owned by:
Priority: low Milestone: None
Component: manipulation Version: 1.7.1
Keywords: Cc:
Blocking: Blocked by:

Description

Suppose you have a truly empty tag:

<span id="foo"/>

If you call $('#foo').empty() it will delete everything AFTER the span within the same parent element.

If the span is defined like this: <span id="foo"></span> then it works correctly.

Tested on Firefox 8.0.1. Tested in jQuery 1.6.1 and 1.7.1.

Here is a simple sample:

<html> <head> <script type="text/javascript" src="js/jquery.js"></script> <script> $(document).ready(function(){

$('#foo').empty();

}); </script> </head> <body> <span id="foo"/> This is after #foo. </body> </html>

Change History

comment:1 Changed 2 years ago by John@…

Withdrawn. Turns out, on further inspection, that Firefox is doing something other than what you would expect. It is wrapping the span around the rest of the contents of the parent object.

comment:2 Changed 2 years ago by sindresorhus

  • Priority changed from undecided to low
  • Resolution set to invalid
  • Status changed from new to closed
  • Component changed from unfiled to manipulation

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.