1

i have these inputs:

<p class='zero'> <? echo $row['perigrafh10']?><input id='zeroin' type ='Text' value ='<? echo $row['poso10']?>' name='poso10'><input class='check' id='check' type='checkbox' <? if ($row['poso10_check'] >=1) {echo 'checked="checked"';}; ?> name='check_list[]' value='<? echo $row['poso10_check']?>' /></p>
<p class='zero'> <? echo $row['perigrafh11']?><input id='zeroin' type ='Text' value ='<? echo $row['poso11']?>' name='poso11'><input class='check' id='check' type='checkbox' <? if ($row['poso11_check'] >=1) {echo 'checked="checked"';}; ?> name='check_list[]' value='<? echo $row['poso11_check']?>' /></p>
....

what i want to achieve is to hide the textbox and the checkbox if the textbox text is 0.00.

i can hide the textbox without issues using this code:

<script type="text/javascript">

 $('input:text').each(function(){
  if($(this).val() == 0.00){
   $(this).hide();
       }
    }
   );
 </script>

but i have no luck to hide the checkboxes too. What code do i need? i ve done several tests but couldnt find solution. i m using latest jquery.

1 Answer 1

1

You want to hide the entire <p> element

$(this).closest(".zero").hide();
Sign up to request clarification or add additional context in comments.

3 Comments

iGanja it worked like a charm. Something deep down in me was saying to hide the whole p element but never tried. Thanks
@Stathis accept this answer if it solved your problem. As a side note, I believe .parent() instead of .closest(".zero") could also work well in this example.
yes, .parent() would work in this case. I like using .closest() so I never have to worry about inserting a parent container later and then everything breaking.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.