1

I am trying to get the id's input elements based on their click functions

   <div>
    <div class="input-group">
     <span>#</span>
     <input id="input1" onclick="foo1()"/>
    </div>
      <input id="input2">
   </div>

   <div>
    <div class="input-group">
     <span>#</span>
     <input id="input3" onclick="foo2()"/>
    </div>
      <input id="input4">
   </div>

   <div>
    <div class="input-group">
     <span>#</span>
     <input id="input5" onclick="foo1()"/>
    </div>
      <input id="input6">
   </div>

I m looking a jquery/javascript that returns id's of input which has click function "foo1"

1
  • Just a side comment that it's really a lot better to find things via id's or class names so if you control the HTML, I'd suggest you set up the class names or id values so you can use them to find what you want. Commented Mar 27, 2014 at 22:19

1 Answer 1

7

It's an attribute, so you can use the attributes selector (there's also attribute starts with, ends with, contains etc)

$('input[onclick="foo1()"]')

FIDDLE

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.