jQuery ListBox Change Options Dynamically

To change any of the widget options dynamically you need to get the initial options, change the desired properties and call the widget refresh(options) method, passing the new values.
This is demonstrated in the code below:

<div id="listbox" ></div>
<script type="text/javascript">
    dataSource: {
        data: countries
    textTemplate: "{name}",
    cls: "MyListBox"
function changeOptions() {
    var listbox = $("#listbox").swidget(),
    options = listbox.initialOptions;
    options.cls = "myTestClass";