title: how to assign the value for global variable in javascript?
body: <p>I use the following script function for get the row <code>id</code> from the grid. It was working properly. I get the ID within the <code>click</code> function. But if I try to get the outside of the function it will display Empty. I need the click function value for <code>selr</code> outside? How to do this?</p>
  
  <pre><code>var selr='';           
  $(document).ready(function(){
                 $("#datagrid").click(function(e) {
                   row = jQuery(e.target).closest('tr');
                   getId= row.attr("id");//for getting row number
                   selr = $("#datagrid").getCell(getId,'companyid');//getting Row ID
                   alert('alert in'+selr);
                   });
                    alert('alert out'+selr);
  });
  </code></pre>