I have this JavaScript function:
function prefixOneDropDown(){
var source = $('#prefix-one');
var selected = source.find('option[selected]');
var options = $('option', source);
var DefinitionList = '<dl id="dd-prefix-one" class="dropdown f-left"><dt><a href="#">' + selected.text() + '<span class="value">' + selected.val() + '</span></a></dt><dd><ul></ul></dd></dl>';
$(DefinitionList).insertAfter(source);
options.each(function(){ $("#dd-prefix-one dd ul").append('<li><a href="#"><span class="number-plate">' + $(this).text() + '</span><span class="value">' + $(this).val() + '</span></a></li>'); });
}
I was wondering if there is a way declaring var selected, options, DefinitionList outside the function...then call them in as arguments?
I've tried a number of different approaches but I'm missing something.
The function is called in my js like so : prefixOneDropDown();
Any help would be Greatly Appreciated, Thanks