.prevUntil() not working - let me explain

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.:slight_smile:

Hi all i fix my problem bay changing my structuring see below.

<div class="product-specs">
	<p>Specs</p>
	<table>
		<thead>
			<tr>
				<th>Class and Spec</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>
					<input type="text" name="class" value="size" disabled="disabled">
					<input type="text" name="spec" value="250x404x359mm" disabled="disabled">
				</td>
			</tr>
		</tbody>
	</table>
</div>

The input fields are in the same <td> tag so now the below jquery can add a edit button to the same <td> tag and the prev can work as well

// Toggle editing button
	$('.product-specs td').hover(function(){
		$(this).append('<span class="editSpec">E</span>');
	},function(){
		$('.editSpec').remove();
	});

// Edit spec row
	$(document).on('click', '.editSpec', function(){
		$(this).prevAll().removeAttr('disabled');
	});

although there was no replays i thought i would give a solution to my problem.
Have a great day.