0

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.

1
  • This code is correct, as far as I can tell. You may want to show complete page causing problem. Commented May 13, 2010 at 17:14

3 Answers 3

2

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..

Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

0

Really weird. Started from scratch again and it worked.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.