Guest User

Untitled

a guest
Oct 17th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. $('_').siblings().css({'_':'_'})
  2.  
  3. .removeClass
  4. .addClass
  5. .toggleClass
  6.  
  7. Add Content after an element close
  8. .append
  9.  
  10. Add Content before an element open tag
  11. .prepend
  12.  
  13.  
  14. change an elements ID Name
  15. .attr('attr-new-id', 'new-id')
  16. .attr('id', 'prop-new-id')'
  17.  
  18. Execute code on a click event:
  19. $(#a-button').on('click,fuction(){
  20. cosole.log('button clicked');
  21. })'
  22.  
  23. $(#a-button').click(fuction(){
  24. cosole.log('button clicked');
  25. });
  26.  
  27. Form Element Selectors
  28. :checkbox
  29. :input
  30. :focus
  31. :selected
  32. :submit
  33.  
  34. The .val() method allows you get or set the value entered into a form element:
  35. // Get the text string currently entered into the input:
  36. $('input:text').val();
  37. // Set a new value for the input by passing in a string:
  38. $('input:text').val('A new value');
  39. // Clear out an input by passing empty quotes into .val():
  40. $('input:text').val('');
  41.  
  42. Email validation
  43. <form id="my-form">
  44. <input type="email" id="my-text-input" />
  45. <input type="submit" />
  46. </form>
  47.  
  48. $('#my-form').on('submit', function(event) {
  49. event.preventDefault();
  50. if ( $('#my-text-input').val() == '' ) {
  51. alert('You missed the field.');
  52. } else {
  53. alert('Thanks for filling the field!');
  54. }
  55. });
  56.  
  57. $('.add-to-cart').click('button', function(event) {
  58. event.preventDefault();
  59.  
  60. var cartCount = parseInt($('.count').html(), 10);
  61.  
  62. $('.count').html(cartCount +=1);
  63.  
  64. // .count = (.count + cartCount);
  65. // $('.add-to-cart').add(cartCount += 1);
Add Comment
Please, Sign In to add comment