"select button change color dynamically"
Bootstrap 4.1.1 Snippet by ALIMUL AL RAZY

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <select id="bgselect" onchange="changeBg()"> <option value="black">Black</option> <option value="blue">Blue</option> <option value="#000080">Navy Blue</option> <option value="gray">Gray</option> <option selected="selected" value="green">Green</option> <option value="yellow">Yellow</option> <option value="orange">Orange</option> <option value="red">Red</option> </select> <div> <ul class="nav nav-tabs"> <li><a>bla</a></li> <li><a>bla</a></li> <li><a>bla</a></li> <li><a>bla</a></li> <li><a>bla</a></li> </ul> </div> </div> </div> <script> function changeBg() { var bg = document.getElementById("bgselect").value; var navs = document.querySelectorAll(".nav.nav-tabs"); var as = navs[0].getElementsByTagName('a'); for(var i = 0; i < as.length; i++) { as[i].style.background = bg; } } </script>
.nav.nav-tabs > li > a { background-color: #c6dfff; margin-right: 5px; padding-left: 20px; padding-right: 20px; cursor: pointer; color: black; }

Related: See More


Questions / Comments: