html - Javascript adding textarea size -


i have form has textarea , includes couple of buttons 1 add additional textarea , other remove textarea 1 @ time unless it’s last one. works except want size of each textarea same original 1 can’t seem figure out i’m doing wrong.

    <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd">  <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">   <head>   <meta http-equiv="content-type" content="text/html; charset=utf-8"/>   <title>cpo exit form</title>   <script type='text/javascript' src='scripts/jquery-1.9.1.js'></script>   <link rel="stylesheet" href = "styles/site2.css"></link> <script type="text/javascript"> $(document).ready(function(){   var counter = 2;     $("#addbutton").click(function () {     if(counter>9){       alert("only 9 areas can added form.");       return false;     }         var newtextboxdiv = $(document.createelement('div'))          .attr("id", 'textboxdiv' + counter);     newtextboxdiv.after().html('<label>'+ counter + ' : </label><textarea style"width: 700px; height: 56px" max="255"></textarea>');     newtextboxdiv.appendto("#textboxesgroup");      counter++;      });        $("#removebutton").click(function () {         if(counter==2){          alert("this last area cannot removed form.");          return false;        }         counter--;       $("#textboxdiv" + counter).remove();     });    });  </script>   </head>  <body>   <div class="total">    <fieldset><legend>action items:</legend>     <div id='textboxesgroup'>      <div id="textboxdiv1">       <label> 1 : </label><textarea style="width: 700px; height: 56px" max="255"></textarea>      </div>     </div>   <input type='button' value='add button' id='addbutton'>   <input type='button' value='remove button' id='removebutton'>  </body>  </html> 

your change sentence

newtextboxdiv.after().html('<label>'+ counter + ' : </label><textarea style"width: 700px; height: 56px" max="255"></textarea>') 

after...

newtextboxdiv.after().html('<label>'+ counter + ' : </label><textarea style"width: 760px; height: 56px" rows="5" style="width: 764px">') 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -