Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery .addType()

Is there a .addType() function for jquery? I know there's a .addClass() to add the class, but I'm appending an input element to a div using the shorthand way and was wondering if there is a .addType() to add the type to the input area i.e text, password, submit.

$(document).ready(function(){
  $("#newnum").click(function(){
    $("#equation").append(
      $("<input/>")
    );
  });
});
like image 389
Vince Avatar asked Dec 07 '22 08:12

Vince


1 Answers

You could just use the shorthand

$('<input type="text">');

There is also the attr() which would let you do the same thing

$('<input>').attr('type', 'text');
like image 176
Schleis Avatar answered Dec 08 '22 21:12

Schleis