我正在教我的自我php和mysql.I創建一個小型商業網站來測試我的技能。 我網頁上多發的形式這樣jquery從相同的形式選擇值
<div class="formInfo"><form name="CartForm" method="post" action="./ajax/addCart.php" class="fixed">
<input name="prodId" type="hidden" value="10" />
<label for="qty">Quantity:</label>
<input name="qty" type="text" id="qty" size="4" maxlength="6" class="qtyBox">
<br>
<input type="submit" name="addtoCart" id="addtoCart" value="Add to Cart" class="btnAdd">
</form>
<div class="formInfo"><form name="CartForm" method="post" action="./ajax/addCart.php" class="fixed">
<input name="prodId" type="hidden" value="7" />
<label for="qty">Quantity:</label>
<input name="qty" type="text" id="qty" size="4" maxlength="6" class="qtyBox">
<br>
<input type="submit" name="addtoCart" id="addtoCart" value="Add to Cart" class="btnAdd">
</form>
<div class="formInfo"><form name="CartForm" method="post" action="./ajax/addCart.php" class="fixed">
<input name="prodId" type="hidden" value="9" />
<label for="qty">Quantity:</label>
<input name="qty" type="text" id="qty" size="4" maxlength="6" class="qtyBox">
<br>
<input type="submit" name="addtoCart" id="addtoCart" value="Add to Cart" class="btnAdd">
</form>
現在,當我點擊透過按鈕,我想顯示隱藏域ID和可見光領域QTA的值(目前點擊形式) 到目前爲止我的代碼是
<script type="text/javascript">
$(document).ready(function(e) {
$('.formInfo').submit(function() {
alert($(this).val())
});
});
</script>
我不out.How告訴jQuery的,我想「ID」和「本」參考參考自身
正是我在尋找的感謝! – user1125033 2012-07-11 21:06:44