And that can be shortened to: var h = $('#header'); if (!h.next(':not(#new)').length) { h.after('<div id="new">test</div>'); }
or, logically, you wouldn't insert two elements with the same ID, so you could simply use if (!$('#new').length) On Nov 29, 4:50 pm, seasoup <[EMAIL PROTECTED]> wrote: > or you can test inside the bind function: > > if ($('#header').next().('attr','id') != "new") { > $('#header').after('<div id="new">tester</div>'); > > } > > On Nov 29, 7:34 am, Dave Methvin <[EMAIL PROTECTED]> wrote: > > > Do you only want the button to work once? If that is the case, use .one > > () instead of .bind().