我正在尝试获取上一个元素。因此,当单击时,.percen
我想提醒前一个元素的值。此刻我得到undefined
. 问题是什么?
<input class="c currency" type="text" name="artigoAlternativo1_C"/>
<input class="d currency percen" type="text" name="artigoAlternativo1_D"/>
<br/>
<input class="c currency" type="text" name="artigoAlternativo1_C"/>
<input class="d currency percen" type="text" name="artigoAlternativo1_D"/>
$.fn.percentageFormat = function () {
this.each(function (i) {
$(this).change(function (e) {
var $curr = $(this);
$curr_ = $curr.prev('.c');
alert(this.value);
alert($curr_.prev().value);
});
});
return this;
}
$(function () {
$('.percen').percentageFormat();
});