title: Programmatically Set JQuery Mobile slider value
body: <p>How do I programmatically set the value of a slider in JQuery mobile? I have the following slider defined:</p>
  
  <pre><code>&lt;label for="optionSlider"&gt;Are you sure?&lt;/label&gt;
  &lt;select id="optionSlider" name="slider" data-role="slider"&gt;
    &lt;option value="no"&gt;No&lt;/option&gt;
    &lt;option value="yes"&gt;Yes&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>When the page is shown, I want to set it to "yes". I know that I can use the "selected" attribute, but because the value will be dynamic,I need to figure out how to set it programmatically. Currently, I'm using the following:</p>
  
  <pre><code>$("#myPage").live("pageshow", function () {
    var flag = "yes"
    if ((flag != null) &amp;&amp; (flag != undefined)) {
      if (isTrackSet == "no") {
        $("#optionSlider", "#myPage").val("no");
      } else {
        $("#optionSlider", "#myPage").val("yes");
      }
    }
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>