How to write jQuery or JavaScript equivalent for CSS -
i have jquery equivalent css when tab clicked shows content. now, i'm able css only. have same function jquery or javascript.
for example, when sun clicked, shows "it sunday" , when mon clicked, shows "it monday" , on.
how can have same functionality jquery or javascript?
@import url('https://fonts.googleapis.com/cssfamily=open+sans:400,600,700'); * { margin: 0; padding: 0; } body { padding: 2px; background: #e5e4e2; } .tabinator { background: #fff; padding: 1px; font-family: open sans; margin-top: 10px; } .tabinator input { display: none; } .tabinator label { box-sizing: border-box; display: inline-block; padding: 5px 0.6%; color: #ccc; margin-bottom: -1px; margin-left: -1px; font-family: courier; font-weight: bold; } .tabinator label:before { content: ''; display: block; width: 100%; height: 15px; background-color: #fff; position: absolute; bottom: -4px; left: 0; z-index: 10; } .tabinator label:hover { color: red; cursor: pointer; } .tabinator input:checked+label { position: relative; color: red; font-weight: bold; background: #fff; border: 1px solid #bbb; border-bottom: 1px solid #fff; border-radius: 5px 5px 0 0; font-size: 22px; } .tabinator input:checked+label:after { display: block; content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0; box-shadow: 0 0 15px #939393; } #content1, #content2, #content3, #content4, #content5, #content6, #content7 { display: none; border-top: 1px solid #bbb; padding: 3px; margin-top: 2px; } #tab1:checked~#content1, #tab2:checked~#content2, #tab3:checked~#content3, #tab4:checked~#content4, #tab5:checked~#content5, #tab6:checked~#content6, #tab7:checked~#content7 { display: block; box-shadow: 0 0 15px #939393; }
<div class="tabinator"> <input type="radio" id="tab1" name="tabs" checked> <label for="tab1">sun</label> <input type="radio" id="tab2" name="tabs"> <label for="tab2">mon</label> <input type="radio" id="tab3" name="tabs"> <label for="tab3">tue</label> <input type="radio" id="tab4" name="tabs"> <label for="tab4">wed</label> <input type="radio" id="tab5" name="tabs"> <label for="tab5">thu</label> <input type="radio" id="tab6" name="tabs"> <label for="tab6">fri</label> <input type="radio" id="tab7" name="tabs"> <label for="tab7">sat</label> <div id="content1"> <p> sunday</> </div> <div id="content2"> <p> monday</p> </div> <div id="content3"> <p> tuesday</p> </div> <div id="content4"> <p> wednesday</p> </div> <div id="content5"> <p> thursday</p> </div> <div id="content6"> <p> friday</p> </div> <div id="content7"> <p> saturday</p> </div>
Comments
Post a Comment