1

I am working on web forms and writing a piece of javascript to hide checkbox and its text but only checkbox is getting hidden Text is still showing the way it was showing earlier.

Here is my view code

<table style="width: 60%">
     <tr>
        <td class="td_150px">
            <asp:CheckBox ID="chkEnddate" runat="server" CssClass="label" Text="End On"
                              onclick="EndSchedule();" TextAlign="Left"/>
         </td>

    </tr>
</table>

So here is my javascript code on click of a radio button i am using below code to hide the checkbox and text but only checkbox is hidden not text.

 var chkEnddate= document.getElementById("ctl00_ContentPlaceHolder1_chkEnddate");
    chkEnddate.style.display = "none";

Can anybody help me to hide checkbox and it's text at the same time using javascript. Thanks in advance.

1
  • Can you show html generated of your checkbox ? where is text ? Commented May 19, 2021 at 6:37

1 Answer 1

2

place the checkbox in the div element and try to hide that div element

<td class="td_150px">
 <div id="chkEnddateBox">
   <asp:CheckBox ID="chkEnddate" runat="server" CssClass="label" Text="End On"
   onclick="EndSchedule();" TextAlign="Left" />
 </div>
</td>

and in the javascript

var chkEnddate= document.getElementById("chkEnddateBox");
chkEnddate.style.display = "none";
Sign up to request clarification or add additional context in comments.

Comments

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.