javascript - jQuery blur event not working -


why blur event in below code not working , alert box pop-ups document ready , not wait blur event. give me suggestion fix it... thanks...

<!doctype html>  <html>  <head>  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>  <script>  $(document).ready(function(){      $("[type=text]").blur(cc("[type=text]"));      $("[type=email]").blur(cc("[type=email]"));      function cc(s){          alert("value: " + $(s).val());      }  });  </script>  </head>  <body>  <input type="text" id="test" value="rev"><br>  <input type="email" id="test" value="mail@example.org">  </body>  </html>

blur() function take function parameter. in code pas result of cc function execution.

you should use anonymous functions:

$(document).ready(function(){     $("[type=text]").blur(function() { cc("[type=text]"); });     $("[type=email]").blur(function() { cc("[type=email]"); });     function cc(s){         alert("value: " + $(s).val());     } }); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -