0

こんにちは、クラス「価格」のテキストボックスがたくさんあります。他のすべてのテキストボックスに最初のテキストボックスと同じ値を入力するだけです。ここに私のコードがありますが、機能していません。

$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>

$sectionwrapper はクラス "section-1" を示します

ありがとう

4

4 に答える 4

1

この JSFiddleデモのように試してください

$('input.price').val($('.price').eq(0).val())

またはこのように

  $('input.price:gt(0)').val($('input.price').eq(0).val()); 

または最初の演算子を使用します。

$('input.price').val($('input.price').first().val());

あなたはあなたが望むどんなイベントでもそれを引っ掛けることができます。変更時にクリックすることができます。

于 2013-03-08T05:25:15.623 に答える
0

これを試して:

$(document).ready(function(){
    $('input.price:gt(0)').val($('input.price:eq(0)').val());
});

JSFIDDLE

于 2013-03-08T05:26:03.463 に答える
0

ここにフィドルがあります

$(".price").on("change",function()
               {$(".price").val($(".price").first().val())
               });
于 2013-03-08T05:34:28.247 に答える
0
  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);
        });
  });
于 2013-03-08T05:36:52.827 に答える