根据第一个textbox jquery的值输入所有textbox
你好,我有很多“价格”类的文本框, 我所要做的就是为所有其他文本框输入与第一个文本框相同的值。这是我的代码,但它不工作根据第一个textbox jquery的值输入所有textbox,jquery,Jquery,你好,我有很多“价格”类的文本框, 我所要做的就是为所有其他文本框输入与第一个文本框相同的值。这是我的代码,但它不工作 $firstprice=$("."+$sectionwrapper).find(".price").first().val(); $("."+$sectionwrapper).find(".price:eq(0)").nextAll(".price").val($firstprice); 我哪里做错了?任何帮助都将不胜感激 编辑 这是我的HTML代码 <div clas
$firstprice=$("."+$sectionwrapper).find(".price").first().val();
$("."+$sectionwrapper).find(".price:eq(0)").nextAll(".price").val($firstprice);
我哪里做错了?任何帮助都将不胜感激
编辑
这是我的HTML代码
<div class="section-1">
<div id="bookin-ad-wrapper">
<div class="booking-wrapper booking-wrapper-5">
<ul>
<li><label class="w50">Pris kr</label><input type="text" value="" class="price numeric required" name="txtSection[1][5][price]" style=""></li>
</ul>
</div>
<div class="booking-wrapper booking-wrapper-6">
<ul>
<li><label class="w50">Pris kr</label><input type="text" value="" class="price numeric required" name="txtSection[1][6][price]"></li>
</ul>
</div>
<div class="booking-wrapper booking-wrapper-0">
<ul>
<li><label class="w50">Pris kr</label><input type="text" value="" class="price numeric required" name="txtSection[1][0][price]"></li>
</ul>
</div>
</div>
</div>
- Pris kr
- Pris kr
- Pris kr
$sectionwrapper表示类“section-1”
谢谢像这样试试
还是这样
$('input.price:gt(0)').val($('input.price').eq(0).val());
或者使用第一个操作符
$('input.price').val($('input.price').first().val());
你可以在任何你想做的事情中勾住它。可能是点击更改 试试这个:
$(document).ready(function(){
$('input.price:gt(0)').val($('input.price:eq(0)').val());
});
这里是
你能给我们看html或者做一把小提琴吗?是的,只有在看到html之后我们才能说。@Adil,我已经更新了这个问题
$(document).ready(function(){
$('input.price:gt(0)').val($('input.price:eq(0)').val());
});
$(".price").on("change",function()
{$(".price").val($(".price").first().val())
});
Try this:
$(document).ready(function(){
$(".section-1").find(".price").first().blur(function () {
var firstprice=$(".section-1").find(".price").first().val();
//alert("val"+ firstprice);
if(firstprice)
$(".section-1").find(".price").val(firstprice);
});
});