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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:13:52+00:00 2026-06-11T12:13:52+00:00

Lets say there is a textbox and a button . On the click of

  • 0

Lets say there is a textbox and a button. On the click of button a function is executed, and on the focusout of textbox, the button is clicked. What I wanna know is, is there a way, I can determine that weather the user clicked the button, or it was triggered by focusout event of textbox, so that I may do some custom work in the click event, if it was triggered by focusout of textbox?

I could write some code, but I don’t even have any idea where to begin with, I know the jQuery event and event.which property, but I wonder if it/they could be useful in this situation?

  • 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-06-11T12:13:53+00:00Added an answer on June 11, 2026 at 12:13 pm

    This depends on how you’re triggering the function from the textarea blur event, if you’re simply triggering the click event using the following approach:

    $('#btn').click(
        function(e){
            buttonActivation(e);
        });
    
    $('#txt').blur(
        function(e){
            $('#btn').click();
        });
    

    Then I’d suggest evaluating the originalEvent object to see what the original event was (if there was no originalEvent then the function was called by a programmatic click event, with jQuery; whereas if the originalEvent.type evaluates to click then the button must have been clicked.

    function buttonActivation(e) {
        if (!e) {
            return false;
        }
        else {
            var oEvent = e.originalEvent;
            if (oEvent === undefined) {
                console.log('Programmatic event');
            }
            else if (oEvent.type == 'click') {
                console.log('User-initiated event');
            }
        }
    }
    

    JS Fiddle demo.

    If, however, you’re using something like the following (simply calling the same function from a different place):

    $('#btn').click(
        function(e){
            buttonActivation(e);
        });
    
    $('#txt').blur(
        function(e){
            buttonActivation(e);
        });
    

    Then I’d recommend either directly assessing e.target or e.type:

    function buttonActivation(e) {
        if (!e) {
            return false;
        }
        else {
            var oEvent = e.type;
            if (oEvent === 'blur') {
                console.log('Programmatically-triggered event, on ' + oEvent);
            }
            else if (oEvent == 'click') {
                console.log('User-initiated ' + oEvent + ' event');
            }
        }
    }
    

    JS Fiddle demo.

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

Sidebar

Related Questions

Lets say that I have this code $(document).ready(function() { $(#changeText).click(function() { $(#textBox).html(My<br><br><br>text<br><br><br>is<br><br><br>changed!); }); });
Lets say there's a function func() which takes two arguments, a and b .
Lets say there is a defect in a program execution in any language like
Lets say there is setup like this: public class MyClass { public void DoSomething(string
Lets say there are two pages with two different html elements which have the
How does CouchDB handles conflicts while doing bi-directional replication? For example: Lets say there
Lets say that there are two tables: Order ID (PK) DateExecuted OrderStep ID (PK)
(This is for a game I am designing) Lets say that there are 2
Lets say for example there are 5 records shown on screen. I want the
Lets say that you have a business object whose current state implies that there

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.