Hi all this is may first post…well except may introduction.
My goal:
I have to make product specs editable by clicking a edit button.
My code
This is the structure for the specs
<div class="product-specs">
<p>Specs</p>
<table>
<thead>
<tr>
<th>Class</th>
<th>Spec</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="text" name="class" value="" disabled="disabled">
</td>
<td>
<input type="text" name="spec" value="" disabled="disabled">
</td>
</tr>
</tbody>
</table>
</div>
This jquery will add a edit button next to the spec row on hover.
$('.product-specs tr').hover(function(){
$(this).append('<td><span class="editSpec">E</span></td>');
},function(){
$('.editSpec').parent('td').remove();
});
My problem
I have a click event that will make the current rows input fields editable when clicking on the edit button
$(document).on('click', '.editSpec', function(){
$('input').prevUntil('tr').removeAttr('disabled');
});
But for some reason it does not work, is it because the input fields are inside the <td> tags?
i’m really new to jquery so sorry if this is a stupid question.
Any help will be great thanks.