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

  • Home
  • SEARCH
  • 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 7947161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:21:12+00:00 2026-06-04T01:21:12+00:00

At its core my issue is the following: $(‘input’).click (e) -> # do some

  • 0

At its core my issue is the following:

$('input').click (e) ->
  # do some things conditionally, depending on the event origin
  false

$('a').click ->
  $('input').click()

So the issue is, how can I tell who started the event.

Please note that in both of the cases (either clicking the input or the link e.target is the same).

Update: I posted the code above here: http://jsfiddle.net/w7faW/1/

Thanks.

  • 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-04T01:21:14+00:00Added an answer on June 4, 2026 at 1:21 am

    You can pass parameters when triggering events programmatically using the trigger function:

    $('input').click (e, target = e.target) ->
      console.log 'target:', target
      false
    
    $('a').click (e) ->
      $('input').trigger 'click', this
    

    There i’m passing an optional argument target which defaults to e.target, and when clicking on the link, the link itself is passed as that parameter. Then you can use that parameter to check which was the triggering element. You can check the different outputs in this jsfiddle.


    However, given this simple example, i must say that this solution is probably a bit confusing, i’d prefer just using the same function as a click handler for both elements (jsfiddle):

    $('input, a').click (e) ->
      console.log 'target:', e.target
      false
    

    Or, if you need to do something different for each element and then something in common for both, you can just use another function for that common behavior:

    $('input').click (e) ->
      # Do something special for the input.
      commonClickHandler this, e
    
    $('a').click (e) ->
      # Do something special for the link.
      commonClickHandler this, e
    
    somethingCommon = (element, event) ->
      # Do something common for both elements.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

By design, Core Data does not issue a VACUUM SQL command to its SQLite
I'm using Jquery mobile, so ignore some of the following overdone css, its not
I'm currently having the following issue in my project: I'm using Core Data to
Imagine you have a PlayN game which uses Guice bindings in its core project:
I am working on a product which uses C++ primarily for its core components.
I am working on a solution, most of its core engine is developed as
I have the following code written to make my lazy second CPU core working.
I have the following mapping: <?xml version='1.0' encoding='utf-8'?> <hibernate-mapping assembly='Core' namespace='Core.Models' xmlns='urn:nhibernate-mapping-2.2'> <class name='Basket'>
Take the following code: $(#docUploadForm).on(submit, function(event) { event.preventDefault(); }); Simple enough so far, right?
I've got the following setup: Site1 (Core) at Core.example.com Site2 (Work1) at Work1.example.com Site3

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.