Quantcast
Channel: Techie Corner » Javascripts
Viewing all articles
Browse latest Browse all 9

jQuery: How to refresh select box

$
0
0

jquery2nd time searching for how to refresh select box using javascript / jquery. I’ve found the solution previously but the code is hidden somewhere else… grrr… Just a note for myself to refer how to refresh select box using javascript / jquery. Hope this helps u too!

To refresh select box using jQuery, refer to the code below:-

// Assuming there is a select box with ID = myselectbox

// this will clear all select box item
$('#myselectbox').children().remove().end();

var s = document.getElementById('myselectbox');

// add item to select box 
s.options[s.options.length] = new Option('', '');
s.options[s.options.length] = new Option('Label 1 here', 'value 1 here');
s.options[s.options.length] = new Option('Label 2 here', 'value 2 here');

Viewing all articles
Browse latest Browse all 9

Trending Articles