[jQuery] Re: Remove an element ONLY if exists

2008-08-19 Thread besh
Karl is completely right. But if you REALLY have a reason to check for its existence you can do this: if ($('#myId').length) { $('myId').remove(); } else { alert('ooops! there's no myID to remove...'); } -- Bohdan Ganicky On Aug 18, 10:11 pm, "Gewton Jhames" <[EMAIL PROTECTED]> wrote: > The

[jQuery] Re: Remove an element ONLY if exists

2008-08-18 Thread Karl Rudd
$('#myid').remove(); If an element with id="myid" doesn't exist it isn't selected and the "remove()" doesn't do anything. One of the beauties of jQuery. Karl Rudd On Tue, Aug 19, 2008 at 6:11 AM, Gewton Jhames <[EMAIL PROTECTED]> wrote: > There's a way to remove a element by his id, but first