title: How to set jQuery UI toggle programmatically?
body: <p>I noticed it is possible to set the value of a jQuery UI slider in the following way:</p>
  
  <pre><code>$("#mySlider").slider("value", 42);
  </code></pre>
  
  <p>This triggers the event handlers attached to the slider as expected.</p>
  
  <p>Now I'm trying to do the same trick using a button (toggle). There does not appear to be a nice way to do this in the <a href="http://jqueryui.com/demos/button/" rel="nofollow noreferrer">API</a>. I might just be missing something simple.</p>
  
  <p>I tried the following with no results:</p>
  
  <pre><code>$("#myButton").button().click();
  </code></pre>
  
  <p>Any ideas how to handle that in this case are welcome. Note that it would be awesome to find a solution that applies for a buttonset as well.</p>
  
  <p><em>Edit</em></p>
  
  <p>Note that I need this particular functionality to simulate the user. Here's some code to illustrate the issue better:</p>
  
  <pre><code>function toggleBrushValue(hotkey, attributeName) {
      shortcut.add(hotkey, function(e) {
          //XXX: the missing part
          $("#" + attributeName).&lt;something?&gt;;
      });
  }
  
  function increaseBrushValue(hotkey, attributeName) {
      shortcut.add(hotkey, function(e) {
          var currentSize = $("#" + attributeName).slider("value");
  
          $("#" + attributeName).slider("value", currentSize + 1);
      });
  }
  </code></pre>