1

I want to bind a click event with the element:

$('a').click(function(){ btn_submit_pressed=false; });

Now, I want to bind this click event with an element which has onClick attribute values, like this:

<a href="javascript:;" onclick="win_zip('fwrite', 'ext3_00', 'ext3_01', 'ext3_02', 'ext3_03');"> 
  <img width="91" height="20" src="<?=$board_skin_path?>/ez.img/post_search_btn.gif" border=0 align=absmiddle> 
</a> 

How can I select all the elements which have values in onClick attributes?

1 Answer 1

2

it should work using an attribute selector:

$('a[onclick]').on('click', function(){ ... });

edit: use (.bind() instead of .on()) for jQuery < 1.7

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

3 Comments

@OpenCode, just a quick note to mention that the on is available since jQuery 1.7 and @Calderan, +1
@OpenCode, and if you want to avoid the inline onclick to happen. You might want to use removeAttr("onclick") since it will most likely trigger before the jQuery click event.
@Calderan, WOW great. jquery select is some mess for me.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.