views:

28

answers:

1

i have this jquery script that is meant to append input boxes, its wont happen, i dont know why?

jquery:

$(document).ready(function() {
    $(".login").click(function(){
        $(".login").hide();
      $("div.swap").append("<input name="username" id="username" type="text" maxlength="16" />");

     });

});

html:

<div class="swap">
 <a class="login" href="#">Login</a>

  </div>
+4  A: 

Your append is using double quotes to wrap the string and in side the string. Try this:

$(document).ready(function() {
    $(".login").click(function(){
       $(this).hide();
       $('<input name="username" id="username" type="text" maxlength="16" />').appendTo("div.swap");
    });
});
PetersenDidIt
@PetersenDidIt, *waaay* off-topic, but I took a glance at your user-page, and then your website. I just thought I'd mention (assuming it's not an in-joke) that your site has a php warning displayed on its upper-edge.
David Thomas