我想通过jquery设置值之一。从字段中获取值并将其设置为另一个字段。有这样的东西:
$(document).on("click", "a.order_products-collection-rescue-add", function({
$(".chosen-select").chosen();
var $product_search = $('order_product');
$product_search.change(
function() {
var single_price = $(this).find('option.single_option:selected').attr('single_price');
$(CURENT INDEX OF COLLECTION ROW).('input.single-price-field').val(single_price);
console.log(this);
}
);
});
一切正常,但是!我如何获得“收藏行”的当前索引?
如果我单击resecue-add按钮,这将嵌入我的新表单,m getting attr single_price from selected option and in new form is second field with class single-price-field, how to get exaclly this form filed ? i don
不知道如何获取此表单的索引。
答案 0 :(得分:0)
$(document).on("click", "a.order_products-collection-rescue-add", function() {
$(".chosen-select").chosen();
var $product_search = $('select.order_product');
$product_search.change(
function() {
var single_price = $(this).find('option.single_option:selected').attr('single_price');
var product_row = $(this).parent().parent().parent();
$(product_row).find('input.single-price-field').val(single_price);
}
);
});