tags:

views:

27

answers:

3

When this fires I see the added li for a split second and then it disappears.... What gives? Using jquery 1.4.2

$(function(){
  $('a#add_phone').click(function () { 
    $('<li>Test</li>').appendTo('ol#phones');
  });
});

Ok so this works in a blank page, but this is in the context of a rails 3 app. Must be something in there, although I can't see what.

+2  A: 

There must be something else there... if you paste that code in a new page with this HTML snippet it should work just fine:

<a id="add_phone">Add it!</a>
<ol id="phones"></ol>

Look for other JS files conflicting with your code, or even the same file, another line. Or maybe CSS if you're using a slow browser (ehem...)

But that code seems flawless..

Seb
+2  A: 

Pretty straightforward code. Are you sure there's not a live handler hiding elements elsewhere?

Sean O
A: 

Really weird. Started from scratch again and it worked.

Cameron