我需要选择上一个控件,在点击一个输入框时,说用户点击一个输入框,a,txtInputB
我需要的值txtInputA
等等..
困难的部分是以前的输入可以是任何人,它可以是以前div
的或atable
或aupdatePanel
或任何东西?我尝试了所有这些但没有一个有效..
$(event.target).prev('input')
$(event.target).prevUntil('input')
$(event.target).prevAll('input')
$(event.target).parent().find('input')
$(event.target).parent().prev('input')
它们适用于一种条件,例如一个文本框,但不适用于另一个。我也发现了这个
但顺便说一句,这个问题和我的不同之处在于,文本框的位置/位置是事先知道的,但就我而言,我不知道它会在div
什么地方。我只知道这个之前的第一个文本框,它可能在页面中的任何地方那么,我怎么得到它?
UPATE 正如我所说,有大量代码,输入可以在页面中的任何位置,但我仍然粘贴了一些代码..
<div id="UpdatePanel12">
<input name="txtDueDate" type="text" value="10 Oct 2012" maxlength="11" id="txtDueDate" Border-Style="Solid" style="font-size:12px;width:80px;" />
</div>
</td>
<td class="TableData" style="width: 35px;">
Time
</td>
<td style="width: 50;">
<input name="txtTime" type="text" value="1 AM" maxlength="10" id="txtTime" Border-Style="Solid" style="font-size:12px;width:49px;" />
</td>
<td class="TableData">
<div>
<span id="lblCustomer">
Customer
</span>
</div>
</td>
<td>
<table >
<tr >
<td >
<div id="UpdatePanel3">
<input name="txtCustomerName" type="text" maxlength="300" id="txtCustomerName" Border-Style="Solid" onfocus="javascript:select();" style="font-size:12px;" />
</div>
</td>
<td>
<div id="UpdatePanel1">
<div id="CustPanal1" class="popupMenu" style="height:50px;width:100px;">
<table style="font-size: smaller; color: Black">
<tr>
<td align="left" style="color: Black">
Add new customer.
</td>
</tr>
</table>
</div>
<input type="submit" name="imgBtnCustomerAdd" value="Add" onclick="ShowAddCustomer();" id="imgBtnCustomerAdd" style="color:White;background-color:#6086AC;border-color:White;border-width:2px;border-style:Solid;font-family:Verdana;font-size:10pt;font-weight:bold;border-radius: 7px; display: none;" />
</td>
</div>
</td>
</tr>
</table>
</td>
<td>
<span><input type="image" name="imgBtnCustAdd" id="imgBtnCustAdd" src="../images/icons.png" alt="Add customer" style="border-width:0px;" /></span></td>
</tr>
</table>
<table id="tblEntry1" width="100%">
<tr>
<td colspan="10">
<div id="UpdatePanel2">
<table class="TableData">
<tr>
<td>
Address :
</td>
<td id="td1" style="width: 475px" nowrap="nowrap">
<span id="lblAddress" class="LabelBkgScrn" style="display:inline-block;font-weight:bold;width:250px;"></span>
</td>
<td>
Priority :
</td>
<td id="td2" style="width: 260px" nowrap="nowrap">
<span id="lblPriority" class="LabelBkgScrn" style="display:inline-block;font-weight:bold;width:60px;"></span>
</td>
<td style="width: 160px" nowrap="nowrap">
<span><input id="chkToday" type="checkbox" name="chkToday" /><label for="chkToday"> Same Day</label></span>
</td>
</tr>
<tr>
<td>
Remarks :
</td>
<td style="width: 470px" nowrap="nowrap">
<span id="lblRemarks" class="LabelBkgScrn" style="display:inline-block;font-weight:bold;width:160px;"></span>
</td>
<td>
Mob. No. :
</td>
<td style="width: 250px" nowrap="nowrap">
<span id="lblMobileNo" class="LabelBkgScrn" style="display:inline-block;font-weight:bold;width:160px;"></span>
</td>
<td style="width: 160px" nowrap="nowrap">
<span><input id="chkNextDay" type="checkbox" name="chkNextDay" /><label for="chkNextDay"> Next Day</label></span>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<table id="tblEntry2" width="100%">
<tr>
<td colspan="15">
<table style="width: 100%">
<tr>
<td>
<div id="pnlEntry" style="height:200px;overflow-y:scroll;">
<div>
<table class="mGridEntry" cellspacing="0" cellpadding="4" rules="all" border="1" id="grdEntry" style="border-collapse:collapse;">
<tr style="color:White;font-size:Small;">
<th scope="col">
<table>
<tr class="mGridCustomHeader">
<td style="color: orange; border-width: 0px">
S.No.
</td>
</tr>
<tr>
<td style="border-width: 0px">
<span id="grdEntry_ctl01_lblHSNo" style="color:Black;">1</span>
</td>
</tr>
</table>
</th><th scope="col">
<table>
<tr>
<td style="color: Orange; border-width: 0px" class="mGridCustomHeader">
Qty
</td>
</tr>
<tr>
<td style="border-width: 0px">
<input name="grdEntry$ctl01$txtQty" type="text" value="1" maxlength="4" id="txtQty" Border-Style="Solid" style="font-size:12px;width:25px;" />
</td>