Triangles can be made using css. Store the state using the checkbox (you can also register an event for it to catch a click). To add arrows, use :before and :after pseudo-classes. You can attach a click on the arrows by applying pseudo-classes to the 'label', which refers to the checkbox by id .
In this option, you can do without scripts to switch the state of the arrows, however, it took me two additional pseudo-classes to switch.
Perhaps this option will suit you.
$('#stateInput').change(function() { console.log('This value is now: ' + $(this).prop('checked')); })
div { font-size: 20px; } .arrows { position: relative; cursor: pointer; } #stateInput { display: none; } #stateInput + .arrows:after { content: ' '; position: absolute; left: 10px; bottom: -16px; border: 10px solid transparent; border-top: 10px solid green; border-width: 12px 7px; } #stateInput:checked + .arrows:after { content: ' '; position: absolute; left: 10px; bottom: -16px; border: 10px solid transparent; border-top: 10px solid gray; border-width: 12px 7px; } #stateInput + .arrows:before { content: ' '; position: absolute; left: 10px; bottom: 12px; border: 10px solid transparent; border-bottom: 10px solid gray; border-width: 12px 7px; } #stateInput:checked + .arrows:before { content: ' '; position: absolute; left: 10px; bottom: 12px; border: 10px solid transparent; border-bottom: 10px solid green; border-width: 12px 7px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div> Some text <input type="checkbox" id="stateInput"> <label for="stateInput" class="arrows"></label> </div>
Added by
With button styling
$('#stateInput').change(function() { console.log('This value is now: ' + $(this).prop('checked')); })
.button { position: relative; font-size: 20px; text-decoration: none; display: inline-block; border: 1px solid green; color: green; } .button:active { color: gray; background: #eee; } .button > .arrows { position: relative; cursor: pointer; display: block; padding: 8px 10px; padding-right: 30px; } .button > input { display: none; } #stateInput + .arrows:after, #stateInput + .arrows:before { content: ' '; position: absolute; right: 10px; border: 10px solid transparent; } #stateInput + .arrows:after { bottom: -6px; border-top: 10px solid green; border-width: 12px 7px; } #stateInput + .arrows:before { top: -6px; border-bottom: 10px solid gray; border-width: 12px 7px; } #stateInput:checked + .arrows:before { border-bottom-color: green; } #stateInput:checked + .arrows:after { border-top-color: gray; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <a href="#" class="button"> <input type="checkbox" id="stateInput"> <label for="stateInput" class="arrows">Some text</label> </a>