i have this html code
<table style="width: 100%;">
<tr>
<td>
ID
</td>
<td>
<input id="Text1" type="text" class="b" />
</td>
</tr>
<tr>
<td>
Name
</td>
<td>
<input id="Text2" type="text" class="b" />
</td>
</tr>
<tr>
<td>
Family
</td>
<td>
<input id="Text3" type="text" class="b" />
</td>
</tr>
<tr>
<td colspan="2">
<input id="Button1" type="button" value="Click Me" />
</td>
</tr>
</table>
i want, if user no enter text select sibling td and get text in td i’m writing this code but no working
$(function () {
$("#Button1").click(function () {
var ls = $(".b");
alert(ls.length);
for (var i = 0; i <= ls.length - 1; i++) {
if ($(ls[i]).val() == "") {
alert("hi");
var ctx = $(ls[i]).parent("td").parent().siblings();;
alert($(ctx).val());
//
alert(ctx.length);
}
}
});
});
for example, if user in Text1 to enter id and press button 1 i want show alert id.
please help me. thanks all
So you want to find the previous
td, the one just before thetdcontaining theinputthat doesn’t have a value? That would be something like this: