Thursday 15 July 2010

javascript - Get child input element value update -



javascript - Get child input element value update -

html code follows:

<div id="input2" class="clonedinput"> <div class="col-sm-3 text_flied"> <div class="col-sm-4 no-padding"> <input type="" class="bwidth" value="" placeholder="300" name="fr_width[1]"> </div> <div class="col-sm-1 text_middle no-padding"> <p>x</p> </div> <div class="col-sm-4 no-padding"> <input type="" class=" bheight" value="" placeholder="300" name="fr_height[1]"> </div> </div> </div>

i want update value of input field fr_width[1]. sections dynamically created fr_width[2], fr_width[3] , on.

to update value, utilize next code, not working. tried children() alternative too.

$("#input2").siblings(".col-sm-4 input").val('123'); $("#input2").closest(".bwidth").val('123');

both ways not working.

try demo :-

$("#input2").find(".text_flied").find(".bwidth").val('123');

or

$("#input2").children(".text_flied").find(".bwidth").val('123');

or

$("#input2").find(".bwidth").val('123');

or

the shortest way can go

$("#input2 .bwidth").val('123');

1)- closest works ancestor or selector .

2)- siblings works same heirarchy nodes.

there lots of ways can find required selector , set value .

thanks !

javascript jquery

No comments:

Post a Comment