Removing Html Element By Id
I am using the following code to remove an element from the DOM tree: function onItemDeleted(name) { $('#' + name).remove(); } Would t
Solution 1:
jQuery optimises for ID searches. So, $("#" + name)
is effectively the same as $(document.getElementById(name))
. From the source, line 120 (1.4):
// HANDLE: $("#id")
} else {
elem = document.getElementById( match[2] );
Solution 2:
The difference in performance would likely be negligible.
Post a Comment for "Removing Html Element By Id"