jquery trigger change event on select code example

Example 1: jquery select box change event

$('select').on('change', function (e) {
    var optionSelected = $("option:selected", this);
    var valueSelected = this.value;
    ....
});

Example 2: trigger change select element jquery

$('#selectField').val(10).trigger('change');

or

$('#selectField').val(10).change();

Example 3: js select and copy on click

document.getElementById("copy-text").onclick = function() {
  this.select();
  document.execCommand('copy');
  alert(window.getSelection().toString());
}

Example 4: javascript remove event listener after bind

var someEventHander=function(){
	console.log("do something");
}
var handlerCopy=someEventHandler.bind(var1,var2)
//add listener
document.getElementById("someid").addEventListener('click',handlerCopy,true);
//remove listener 
document.getElementById("someid").removeEventListener('click',handlerCopy,true);