JavaScript Prevent alert first time using jquery/ javascript

I want to attached function on click event on document. My function is attached it but it is calling it also. I don't understand why. Demo

$(function () {
    $('a').click(function () {
        $(document).bind('click', perform)
    })
})
function perform() {
    alert(0)
}
Answer:1

the event 'bubbles', firing upon both the a element and its parents, you can force jquery to stop further events from firing above this element like so:

http://jsfiddle.net/4yHC4/2/

$(function () {
    $('a').click(function (e) {
        $(document).bind('click', perform)
        e.stopPropagation();
    })
})

function perform() {
    alert(0)
}
Answer:2

Try this one before the click event

          $(document).unbind("click");
          $(document).bind("click" , perform);
Answer:3

I am brand new to Angular, and have read through all the tutorials, but am at the steep point of the learning curve where I'm building a real application for the first time. I want to show a div ...

I am brand new to Angular, and have read through all the tutorials, but am at the steep point of the learning curve where I'm building a real application for the first time. I want to show a div ...

this is my html code <table id='code'> <tr> <td>data1</td> <td>data2</td> <td>data3</td> <td class='action'>...

this is my html code <table id='code'> <tr> <td>data1</td> <td>data2</td> <td>data3</td> <td class='action'>...

  1. jquery click event not firing
  2. jquery click event listener
  3. jquery click event target
  4. jquery click event firing twice
  5. jquery click event not working on mobile
  6. jquery click event get element
  7. jquery click event on class
  8. jquery click event function
  9. jquery click event stop propagation
  10. jquery click event parameters
  11. jquery click event only works once
  12. jquery click event get element id
  13. jquery click event for dynamic elements
  14. jquery click event on anchor tag
  15. jquery click event pass parameter
  16. jquery click event on pseudo element
  17. jquery click event on element
  18. jquery click event on disabled input
  19. jquery click event order
  20. jquery click event get href

I just started using RequireJs. Only one problem. Can someone explain why the code inside the require block is not run on page refresh. It only runs when I clear the cache. example: require(['game','...

I just started using RequireJs. Only one problem. Can someone explain why the code inside the require block is not run on page refresh. It only runs when I clear the cache. example: require(['game','...

  1. window onload run function
  2. window onload run script
  3. window.onload not running
  4. window.onload function not running

It looks pretty easy but I'm unable to do it. I want to change the view after click on login button, this is my code: app.js Ext.require ('Ext.container.Viewport'); Ext.application({ name: 'MyApp',...

It looks pretty easy but I'm unable to do it. I want to change the view after click on login button, this is my code: app.js Ext.require ('Ext.container.Viewport'); Ext.application({ name: 'MyApp',...

  1. switch view in android
  2. switch view in outlook
  3. switch view in swift
  4. switch view in servicenow
  5. switch view in android example
  6. switch view in angularjs
  7. switch view in skyrim
  8. switch view in iphone
  9. switch in view mvc