try instead of $(".lab_"+input_name+" #test").hide(); this: $(".lab_"+input_name+" ").children("#test").remove(); or if you don't want to actually remove them: $(".lab_"+input_name+" ").children("p").hide();
Hope this helps On 13 May, 14:02, vmoravek <vojtech.mora...@googlemail.com> wrote: > Hi all, > I found same strange behavior when I trying hiding, or removing DIVs > inside form. > > Please look on my sample here:http://62.245.92.202/jquery-sample.php > > Expected behavior is: > > When I make change inside input field “one” text “lorem ipsum” will be > shown between “one” and input:text field. When another change is made > “lorem ipsum” text will be remove and shown again. So every time there > will be only one text “lorem ipsum” > > This scenario works great only in field “one” when try to fill another > fields “two” or “three” “lorem ipsum” text will not hide and will be > shown again and again bellow last one. > > Please, could you check my script and tell me what I doing wrong? > > Thank you > Vojtech > > Whole script from sample for copy/paste: > > <head> > > <script src="http://jquery.com/src/jquery-latest.js" type="text/ > javascript"></script> > <script type="text/javascript"> > $(document).ready(function(){ > $("#cust_registration input:text").change(function() { > > var input_name = $(this).attr("name"); > > $(".lab_"+input_name+" #test").hide(); > > $("label[for="+input_name+"]").after("<p > id=\"test\"><strong> > lorem ipsum </strong></p>"); > > }); > }); > </script> > </head> > > <body> > > <div class="customer_login_form"> > <form id="cust_registration" method="" action=""> > > <div class="lab_one"> > <label id="" class="form_desc" > for="one">one</label> > </div> > > <div> > <input id="one" class="inputbox" type="text" > name="one"> > </div> > > <div class="lab_two"> > <label id="" class="form_desc" > for="two">two</label> > </div> > > <div> > <input id="two" class="inputbox" type="text" > name="two"> > </div> > > <div class="lab_three"> > <label id="" class="form_desc" > for="three">three</label> > </div> > > <div> > <input id="three" class="inputbox" > type="text" name="three"> > </div> > > </form> > </div> > </body>