如何在单击旁边的图标时仅访问特定的文本框。我知道我必须使用 $this,但是作为新手我无法做到。帮助表示赞赏。:)
JS:
jQuery(document).ready(function($) {
$('#plus').click( function(event) {
if($('.abc').val() == ''){
$('.abc').val(10);
}else{
$inc = parseInt($('.abc').val()) + 10;
$('.abc').val($inc);
}
});
});
HTML:
<form class="chkform" id="chkform" name="chkform" method=post action="">
<input type="text" class="abc" id="abc" name="abc" value="">
<img src="plus.png" id="plus" name="plus" class="plus" >
<br><br>
<input type="submit" value="submit" name="submit" >
</form>
<form class="chkform" id="chkform" name="chkform" method=post action="">
<input type="text" class="abc" id="abc" name="abc" value="">
<img src="plus.png" id="plus" name="plus" class="plus" ><img src="minus.png" id="minus" name="minus" class="minus">
<br><br>
<input type="submit" value="submit" name="submit" >
</form>