title: How to assign a variable using onclick of html?
body: <p>I am writing a code where the onclick of html should cause a javascript variable to be assigned a value which causes a function to trigger.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function set_str(numb)
   {
     if(numb == 1)
     var str_in_func = 'a.tab_1';
     else if(numb == 2)
        var str_in_func = 'a.tab_2';
     return str_in_func;
  }
  jQuery(window).bind("load", function() {
  str = set_str(num);
  
  // When a link is clicked
  $(str).click(function () {
  
  
  // switch all tabs off
  $(".active").removeClass("active");
  
  // switch this tab on
  $(this).addClass("active");
  
  // slide all content up
  $(".content").slideUp();
  
  // slide this content up
  var content_show = $(this).attr("title");
  $("#"+content_show).slideDown();
  
  });
  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>I want the javascript variable str to have a value of 'a.tab_1' when the link below is clicked</p>
  
  <pre><code>&lt;a href="#" title="content_1" onclick="var num = 1; return false;" class="tab_1 active" id="ma_link"&gt;Topics&lt;/a&gt;
  </code></pre>
  
  <p>This doesn't seem to work though. The above jQuery function doesn't run at all.</p>