Hide element from DOM in jQuery

Last Reply one month ago By pandeyism

Posted one month ago
Dear All,
 
I am new to Jquery, Please help me.
 
I need to remove the text 'Commercial' and 'Government' from the DOM HTML.
 
I have tried with the below code, It did not work 
:this.element.find('Government').hide();

 

You are viewing reply posted by: pandeyism one month ago.
Posted one month ago

Hi bhadriau,

Refer below sample.

HTML

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        if ($("#lblCommercial").text() == 'Commercial') {
            $("#lblCommercial").closest('label').hide();
        }
    });
</script>
<label><input type="radio" id="chkCommercial" /><span id="lblCommercial">Commercial</span></label>
<br />
<label><input type="radio" id="chkGovernment" /><span id="lblGovernment">Government</span></label>

Demo