title: Passing variables in jquery
body: <p>What is the best way to pass the var full to function b. I don't want to use global variables. Is return the only option. </p>
  
  <pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; 
  
  &lt;style&gt; 
      .aaa, .bbb, .ccc { width:100px; height:100px;background-color:#ccc;margin-bottom:5px;}
  &lt;/style&gt;
  &lt;body class="123"&gt;
  
      &lt;p id="ptest"&gt;&lt;/p&gt;
      &lt;p class="aaa" id="aaaid"&gt;&lt;/p&gt;
      &lt;p class="bbb" id="bbbid"&gt;&lt;/p&gt;
      &lt;p class="ccc" id="cccid"&gt;&lt;/p&gt;
      &lt;div&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;script type="text/javascript"&gt;
      $("body").click(function(e){
          var name = $(e.target)[0].nodeName;
          var nameid = $(e.target)[0].id;
          var classname = $(name+"#"+nameid).attr('class');
          var full = name+"#"+nameid;
          console.log(nameid);
  
          function b(){
              alert(full);
          };
      });
  &lt;/script&gt;
  </code></pre>