Accepted answer

Since you're creating the drop down in the HTML, you don't need to append anything using D3.

Thus, drop this:

var select ='#opts')
    .on('change',function() { update(this.value) });

And simply add an event listener to the dropdown:"#opts").on("change", function() {
    //code here

Here is a demo:"#opts").on("change", function() {
<script src=""></script>
<select id="opts">
  <option>Please select</option>
  <option value="ds1">1</option>
  <option value="ds2">2</option>
  <option value="ds3">3</option>

Related Query