Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6473007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:24:50+00:00 2026-05-25T06:24:50+00:00

I have a div with a class name ‘form’. When the page is initially

  • 0

I have a div with a class name ‘form’. When the page is initially loaded this div is hidden (it’s an asp.net web forms Panel control). The panel is displayed when a search button is clicked to open a search form on the page. I need to capture when the user hits enter in any of the textboxes and have it click the Search button which I’ve added a class named ‘form-default’.

The problem I have is that my event handler isn’t hooked up because because ‘form’ wasn’t visible when the page was initially loaded and so couldn’t access my textboxes. I could have them attach when the form is opened but I’m trying to get a small code snippet that can be loaded in a global file so that we can easily alot class names of ‘form’ to div’s and ‘default-form’ to buttons within the div to have default buttons within the page in more than one place. I don’t want developers to need to remember to hook up the calls when the UI changes. Can I use live() to hook this up or am I doing something else wrong?

$(".form").find(".ec-text").keydown(function(e){
if (e.which == $.ui.keyCode.ENTER){
this.closest(".form-default").click();
}
}); 

EDIT: This works fine:

$(".ec-text").live("keydown", function(e){
    if (e.which == $.ui.keyCode.ENTER){
        this.closest(".form-default").click();
    }
});

BUT I need to attach the event handler to items ONLY inside a .form div. Applying this:

$(".form").find(".ec-text").live("keydown", function(e){
        if (e.which == $.ui.keyCode.ENTER){
            this.closest(".form-default").click();
        }
    });

doesn’t work. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:24:51+00:00Added an answer on May 25, 2026 at 6:24 am

    The easiest thing would be to change your live binding code so that it will bind only to items that are inside the form. (Your code didn’t work because the .find sort of breaks the way that live handlers work.)

    $(".form .ec-text").live("keydown", function(e){
        if (e.which == $.ui.keyCode.ENTER){
            this.closest(".form-default").click();
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form element defined as: <div class=field> <div class=name> <label for=User_LastName> Last
I have something like the following <div id=container> <ul id=name_list> <li class=name> <input type=hidden
I have some class like this <div class = student> <div class = name>Adam
I have many DIV with the same class name, let save wmplayer. I want
I have a div having a css class MyClass. Inside this div, I can
I have this div inside a repeater, where i set the class, onmouseover and
I have this HTML code: <div class='com_box'> <div class='com_box_c'> <div class='com_box_info'> <a id='quote'>quote</a> </div>
say I have a css class name div.TestClass { float:left;etc// } span.SpanTestClass { float:right;etc//
I have a two divs which have class name container. Each of this divs
I have div having class name .modalPopup inside the div I have multiple table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.