Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i want to display a small vertical line on my webform which should only appear(or become visible) when i check a checkbox. Line should become invisible when i untick the checkbox how can i do that?
Posted
Comments
Thanks7872 25-Sep-15 9:18am    
By coding. By effort.

You can do it in a very easy way like:

HTML:

HTML
<input id="chkTest" type="checkbox" />
<div>Some Text</div>
<hr id="horizontalLine" />
<div>Some More Text</div>


CSS:

CSS
#horizontalLine{
    display:none;
}


JS:

JavaScript
$(function () {
    $("#chkTest").change(function () {
        $("#horizontalLine").toggle(this.checked);
    });
});


DEMO: FIDDLE[^]
 
Share this answer
 
v2
You haven't shared enough information, I'm helping you with my assumption.
HTML
<form>
    <div class="line"></div>
    <input type="checkbox" />
</form>

CSS
.line{
    height:200px;
    width:2px;
    background-color:#f44;
    display:none;
}

.show-line{
    display:block;
}

JavaScript
$("input[type='checkbox']").change(function() {
    $(".line").toggleClass("show-line");
});

Hope it helps.

-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900