you have such a strange case and code here.
After removing it, you must add it or add it again.
$(document).ready(function(){ var $one = $('#1'); var $two = $('#2'); var $twitter = $('#twitter'); $one.click(function () { $one.hide(); $two.show(); $twitter.remove(); }); $two.click(function () { $one.show(); $two.hide(); $twitter.parent().append('<input id="twitter" type="hidden" name="twitter" value="yes"/>'); }); });
instead of "hard coding" the element, you can use a template, for example, a jQuery or mustache.js template, etc.
I usually use iCanHaz. so the code could be like that
$twitter.parent().append(ich.twitter({value: 'yes'});
and you define twitter in
<script id="twitter" type="text/html"> <input id="twitter" type="hidden" name="twitter" value="{{value}}"/> </script>
source share