title: Disabling select element when checkbox is checked with jQuery
body: <p>I want to make a script which will disable a select form element upon checking desired checkbox. Since there will be more times I will use this, I wanted to make it as a function which takes target selection id as an argument. The problem is, this function doesn't work when I'm passing the id as argument. On the contrary, it seems to work with hard-coded id.</p>
  
  <pre><code>&lt;select id="worldSelect" class="select" name="world"&gt;
  &lt;input id="worldcb" type="checkbox" checked="yes" value="any" name="world"&gt;
  
  function toggleSelection(id){
      var el = '#' + id;
      if (this.checked) {
          $(el).attr('disabled', 'disabled');
      } else {
          $(el).removeAttr('disabled');
      }
  }
  
  $(function() {
      toggleSelection('worldSelect');
      $('#worldcb').click(toggleSelection);
  });
  </code></pre>