title: Make default button using JavaScript/JQuery
body: <p>I have 3 Divs as below:</p>
  
  <pre><code>&lt;div id="div1"&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;Telerik:RadTextBox ID="RadTextBox1" runat="server"&gt;
                  &lt;/Telerik:RadTextBox&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;Telerik:RadTextBox ID="RadTextBox2" runat="server"&gt;
                  &lt;/Telerik:RadTextBox&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;Telerik:RadComboBox ID="RadComboBox1" runat="server"&gt;
                      &lt;Items&gt;
                          &lt;Telerik:RadComboBoxItem Value="1" Text="First" /&gt;
                          &lt;Telerik:RadComboBoxItem Value="2" Text="Second" /&gt;
                      &lt;/Items&gt;
                  &lt;/Telerik:RadComboBox&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;Telerik:RadButton ID="RadButton1" runat="server" Text="Button 1"&gt;
                  &lt;/Telerik:RadButton&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  &lt;div id="div2"&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;Telerik:RadTextBox ID="RadTextBox3" runat="server"&gt;
                  &lt;/Telerik:RadTextBox&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;Telerik:RadTextBox ID="RadTextBox4" runat="server"&gt;
                  &lt;/Telerik:RadTextBox&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;Telerik:RadComboBox ID="RadComboBox2" runat="server"&gt;
                      &lt;Items&gt;
                          &lt;Telerik:RadComboBoxItem Value="1" Text="First" /&gt;
                          &lt;Telerik:RadComboBoxItem Value="2" Text="Second" /&gt;
                      &lt;/Items&gt;
                  &lt;/Telerik:RadComboBox&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;Telerik:RadButton ID="RadButton2" runat="server" Text="Button 2"&gt;
                  &lt;/Telerik:RadButton&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>If any of the textboxes or combobox (and there are additional html elements like calendar control etc) is focused, then I would like to set that divs button as default button when the enter is pressed.</p>
  
  <p>I tried the code as below just for the RadTextBoxes:</p>
  
  <pre><code>$().ready(function() {
                  $(document).keypress(function(e) {
                      if ((e.which &amp;&amp; e.which == 13) || (e.keyCode &amp;&amp; e.keyCode == 13)) {
                          e.preventDefault();
                          if ($('#div1 input').is(":focus")) {
                              alert("div1");
                          }
                          else if ($('#div2 input').is(":focus")) {
                              alert("Inside div2");
                          }
                          else {
                              return false;
                          }
                      }
                  });
              });
  </code></pre>
  
  <p>I see it does not get inside into either of the If clauses. Could someone help me?</p>