You are viewing limited content. For full access, please sign in.

Question

Question

Some Javascript's even doesn't work

asked on April 16, 2018

Hi all,

 

I have a form with javascript's event.

Actually, I have an alert popup message when the user wrote in the  field 12.

 

And this is working!

 

Now, I want to change this "keyup" even to something else (example : "focus")

This is doesn't work with :

focus, onfocus, blur, onblur

 

This is working with :

click, keyup, ready, change.

0 0

Answer

SELECTED ANSWER
replied on April 16, 2018 Show version history

Olivier,

Instead of 

$('#q12').focus(function(){
    //your code here
});

Try

$('#q12 input').focus(function(){
    //your code here
});

My guess is it isn't working because the ID is attached to the parent rather than the actual input field so that event you're currently targeting doesn't actually fire.

If you are using something other than an input, replace input with the appropriate element type (select, textarea, etc.).

Keyup, keydown, etc. are working because those events happen within the scope of the parent, but others are limited to the actual input element.

1 0
replied on April 16, 2018

Hi Jason,

 

Thank you for your help.

I was 2 mistake. This is about "input" and my ";" at my function's end.

 

It's working now.

Thank you very much.

 

Regards

 

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.