JavaScript Trigger event from inside event hander has different behavior in IE10 trigger event from parent to child angular,trigger event from

I want to trigger a blur within a keypress. IE10 works differently from Chrome/FF. It appears that IE will finish the keydown handler before calling the blur handler, whereas Chrome and FF will trigger the blur handler right when the blur occurs and then go back to finish the keypress handler.

I'm wondering if this is a bug and if there is a good workaround in IE to work like Chrome and FF.

See the code below.

 $(document).ready(function () {
     document.getElementById("txtInput").addEventListener('blur',
     function (event) {
         console.log('blur');
     });

     document.getElementById("txtInput").addEventListener('keydown',
     function (event) {
         console.log('down 1');
         document.getElementById("txtInput").blur();
         console.log('down 2');
     }
     );
 });

http://jsfiddle.net/244raf1u/

Output from Chrome:

down 1
blur
down 2

Output from IE

down 1
down 2
blur
Answer:1

Try this:

$(document).ready(function () {

     $("#txtInput").blur(function (event) {
         event.preventDefault();
         console.log('blur');
     });

     $("#txtInput").keypress(function (event) {
         console.log('down 1');
         $(this).blur();
         console.log('down 2');
     });

 });

Check out the changes I made in this updated fiddler here.

I had to change the way you were calling the blur() trigger, and then added a simple event.preventDefault() in the blur() handler to prevent a second firing in IE. It seems like IE was trying to move focus off of that input after running the keypress handler.

Also by using this notation: ($("#txtInput")[0]) you are actually referring to the original element object and not the jQuery object, which may be causing issues in IE where the other two are catching the error.

Hopefully this will help!

Answer:2

i have a html page in which i have a number of anchor tags i want to add rel="no follow" attribute in anchor tag if it doesn't have it on the pages whose source is starting with hyper text transfer ...

i have a html page in which i have a number of anchor tags i want to add rel="no follow" attribute in anchor tag if it doesn't have it on the pages whose source is starting with hyper text transfer ...

This J fiddle utilizes getElementsByClassName http://jsfiddle.net/YZTpn/ This j fiddle uses getElementByID http://jsfiddle.net/9Fa89/ <script> when I print out the length of the var "x".... ...

This J fiddle utilizes getElementsByClassName http://jsfiddle.net/YZTpn/ This j fiddle uses getElementByID http://jsfiddle.net/9Fa89/ <script> when I print out the length of the var "x".... ...

  1. difference between length and width
  2. difference between length and height
  3. difference between length width and height
  4. difference between length and length() in java
  5. difference between length and depth
  6. difference between length and inseam
  7. difference between length and distance
  8. difference between length and size in java
  9. difference between length and size in c++
  10. difference between length and size in matlab
  11. difference between length and volume mascara
  12. difference between length and diameter
  13. difference between length and format in sas
  14. difference between length and count in c#
  15. difference between length and lengthb in oracle
  16. difference between length and precision in sql server
  17. difference between length and height in pediatrics
  18. difference between length and span of a bridge
  19. difference between length and magnitude of a vector
  20. difference between length and lap in swimming

I have a form that I am trying to use page two as a continuation page that will only be shown when a user checks a box. I am using Adobe Acrobat DC cloud and I tried the following code. if (this....

I have a form that I am trying to use page two as a continuation page that will only be shown when a user checks a box. I am using Adobe Acrobat DC cloud and I tried the following code. if (this....

  1. show hide page breaks in word
  2. show hide page javascript
  3. show hide page elements
  4. excel show hide page breaks
  5. jquery show hide page jumps
  6. excel show hide page number
  7. show hide tab page c#
  8. show hide div page refresh
  9. html show hide page
  10. show/hide div on page load javascript
  11. show hide div without page refresh
  12. show hide content web page
  13. power bi show hide page
  14. pdf javascript show hide page
  15. adobe acrobat show hide page
  16. jquery show hide on page load
  17. show hide div from another page

I am writing a directive which is really simple: it should wrap an input element in a div. I use transclusion for this. The problem is that it breaks ng-model for some reason. Please see this plunker ...

I am writing a directive which is really simple: it should wrap an input element in a div. I use transclusion for this. The problem is that it breaks ng-model for some reason. Please see this plunker ...