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 6687197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:15:36+00:00 2026-05-26T05:15:36+00:00

How can I alert a message once the input is focused, of the following

  • 0

How can I alert a message once the input is focused, of the following HTML code:

<div class="ss_datesel_inp_cont">
    <div class="ss_datesel_inp_right_corner"> </div>
    <input autocomplete="off">
</div>

This is what I tried but none works:

$(".ss_datesel_inp_cont:input").click(function() {
    alert("focused");
});

// or

$(".ss_datesel_inp_cont:input").focus(function() {
    alert("focused");
});

//or 

$(".ss_datesel_inp_cont").find("input").focus(function() {
    alert("focused");
});
  • 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-26T05:15:37+00:00Added an answer on May 26, 2026 at 5:15 am

    The :input selector will only work if the the given element is an input (also textarea, select, and others). The .ss_datesel etc. class is not on the input, it’s on the div. You can simply use a descendant selector instead:

    $(".ss_date_etc input").click(function() { alert('focused'); });
    

    However, this will only work if click the input. If you focus it by tabbing or automatically, the alert won’t occur. Problem is, if you use .focus, alert() steals the focus and then reapplies it in some browsers and you will be stuck in a focus loop. Here’s a simple solution:

    $(".ss_date_etc input").focus(function () {
       if (!$(this).data('focused')) {
          $(this).data('focused', true);
          alert('focus!');
       }
    });
    

    Note that not all browsers will restore focus after an alert, even if you try to force them to. You may want to use some alternative to alert, especially because that would be really annoying to users.

    You can also update .data('focused') to false on blur so this happens over again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone explain why the alert() in the following JavaScript code is firing? It
Can anyone tell me why the following code produces the alert box that I
The following code import gtk import nautilus import os def alert(message): A function to
How can I display an alert or a message after a user clicks a
how can I give an alert when one div hovers over another div upon
Can someone please explain why am I not getting this alert message when clicked
A tester said that he got this message only once, and I can't seem
In laravel for showing all error messages at once i use the following code
How can I repeatedly play a sound while a javascript alert message is up
How can i change the title (usually the domain) that comes in a window.alert(message)

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.