jQuery addClass example

Change class name on click in jQuery

by itamark

HTML

<select name="" id="hello">
    <option value="a" selected>a</option>
    <option value="world">world</option>
    <option value="darkness">darkness</option>
</select>

JavaScript

// find elements
var select = $("#hello")

console.log(select[0].value); // prints a

// handle click and add class
select.on("change", function(e){
  console.log(e.target.value) // prints selection
})