Get value of last option of a drop down?

With jQuery it’s super easy:

var lastValue = $('#idOfSelect option:last-child').val();

With plain Javascript it’s not much worse:

var theSelect = document.getElementById('idOfSelect');
var lastValue = theSelect.options[theSelect.options.length - 1].value;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)