plain text to input text on click using javascript -


i have table needs edit buttons in each row, on click plain text should become input, i've read many tutorial understand none new javascript, can help? started with:

    <script type="text/javascript">                 function edit(clickedbutton){      //get row of clicked button      var row = clickedbutton.closest('tr');  'retrieve each info      var tdid = row.cells[0];     var tdfirstname = row.cells[1];     var tdlastname = row.cells[2];     var tddob = row.cells[3];     var tdgender = row.cells[4];     var tdstatud = row.cells[5];         </script> 

and in table:

<table id="table" class="table .table-bordered" style="width:80%">             <thead>                 <tr>                     <th>id</th>                     <th>first name</th>                     <th>last name</th>                     <th>dob</th>                     <th>gender</th>                     <th>martial status</th>                     <th>action</th>                 </tr>             </thead>             <tbody>                 <tr id="frow">                     <td>1</td>                     <td>samir</td>                     <td>khattar</td>                     <td>1-12-1990</td>                     <td>male</td>                     <td>married</td>                     <td>                         <button onclick="edit(this)">edit</button>                         <button onclick="delete(this)">delete</button>                     </td>                 </tr>             </tbody>         </table> 

and whats difference between .innerhtml , .html

at first take form input want. hide input area default. , show showing table inside form. if of button clicked hidden input area shown , the default table row hidden. idea so.

innserhtml javascript dom property. return dom's inner html, can used change inner html of dom. on other hand, html() jquery library function same work. may method of jquery use innserhtml property. know performance of innerhtml , & html() can check out link: .append vs .html vs .innerhtml performance

best of luck


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -