Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. <form>
  2. ...
  3. <input type=submit name=name1 ...>
  4. <input type=submit name=name2 ...>
  5. </form>
  6.  
  7. $('#searchForm').bind( 'submit', function() {
  8. bx_loading('searchForm', true);
  9. var sQuery = $('input', '#searchForm').serialize();
  10. $.post('searchKeywordContent.php', sQuery, function(data) {
  11.  
  12. $('#searchArea').html(data);
  13. bx_loading('searchForm', false);
  14. }
  15. );
  16. return false;
  17. }
  18. );
  19.  
  20. <form action="">
  21. <input type="submit" name="opa1">
  22. <input type="submit" name="opa2">
  23. </form>
  24.  
  25. <script type="text/javascript">
  26. $('form').on('click', 'input[type="submit"]', function(e) {
  27. e.preventDefault();
  28. submitForm();
  29.  
  30. // console.log($(this).attr('name'));
  31. });
  32.  
  33. $('form').on('submit', submitForm);
  34. </script>
  35.  
  36. function Название функции([Объект event]) {
  37. // ...
  38. }
  39.  
  40. $("р, div").click(function(е) {
  41. $("#divl")
  42. .append("Элемент " + e.srcElement.tagName + "<br>");
  43. });
  44.  
  45. $('form').on('submit',function(e) {
  46. var $btn = $(document.activeElement,this);
  47. if ($btn.is('button, input[type="submit"], input[type="image"]') && $btn.is('[name]'))
  48. {console.log($btn);}
  49. return false;
  50. });
  51.  
  52. <form id="form" action="">
  53. <input type="text" placeholder="Enter your name"/>
  54. <input class="submit-1" type="submit" value="Button 1"/>
  55. <input class="submit-2" type="submit" value="Button 2"/>
  56. </form>
  57.  
  58. $('#form :submit').on('click', function (e) {
  59. if($(e.target).is('.submit-1')) {
  60. console.log('click submit 1');
  61. } else {
  62. console.log('click submit 2');
  63. }
  64. });
  65.  
  66. $('#form').on('submit', function(e){
  67. //alert(e.relatedTarget.name);//не работает в Chrome и FF
  68. alert($(document.activeElement,this)[0].name);
  69. return false;
  70. });
  71.  
  72. $('#youForm').on('submit', function() { $(this).css('color', '#fff'); });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement