How to find all custom elements in form and convert it to inputs with same value? Here is the example code: http://jsfiddle.net/irider89/jsL28xno/4/
$(function() {
$(".triggeredit-card-list").click(function() {
var UsrName = $('.card-list-table').find('#nameEditable').html();
console.log(UsrName);
$('.card-list-tabe').find('#nameEditable').html('<input type="text" class="editable-table" name="editname" id="edittext" value="'+ UsrName +'" />');
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<form id="flip-scroll" class="table-responsive card-list-table">
<table class="table table-custom">
<thead>
<tr>
<th>Номер карты</th>
<th>Ф.И.О.</th>
<th>Дата выдачи</th>
<th>Состояние</th>
<th>Сумма на карте</th>
<th>Категория</th>
<th>Суточная норма</th>
<th>Месячная норма</th>
<th>Выбранная норма за месяц</th>
<th>Вес карты</th>
<th>Комментарий</th>
</tr>
</thead>
<tbody>
<tr>
<td>5757427</td>
<td class="" id="nameEditable">Петров Иван Иванович 1</td>
<td>25.12.2013</td>
<td>Все</td>
<td>3 300</td>
<td>Дизель</td>
<td>123</td>
<td>26</td>
<td id="monthValue">1</td>
<td>2</td>
<td>Комментарий</td>
<td>
</td>
</tr>
<tr>
<td>69594894</td>
<td id="nameEditable">Константинопольский Яков Аристархович</td>
<td>27.12.2013</td>
<td>Все</td>
<td>3 300</td>
<td>123</td>
<td>123</td>
<td>25</td>
<td>1</td>
<td>2</td>
<td>Комментарий</td>
<td>
</td>
</tr>
<tr>
<td>5757427</td>
<td id="nameEditable">Петров Иван Иванович</td>
<td>25.12.2013</td>
<td>Все</td>
<td>3 300</td>
<td>123</td>
<td>123</td>
<td>25</td>
<td>1</td>
<td>2</td>
<td>Комментарий</td>
<td>
</td>
</tr>
</tbody>
</table>
</form>
<button class="btn btn-info btn-triggeredit triggeredit-card-list"><i class="glyphicon glyphicon-pencil"></i> Редактировать</button>
I need to convert to input Ф.И.О. and Выбранная норма за месяц, but to put this values to the input.
its an example of one of your inputs, according to your jsFiddle
You should use
replaceWith
to replace the elemnt, html just changes theinnerHtml
of the elementif you want just replace the content in
th
useIn general it is
If you want all
th
which have classeditable
to be replaced with input use the code below