Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('_').siblings().css({'_':'_'})
- .removeClass
- .addClass
- .toggleClass
- Add Content after an element close
- .append
- Add Content before an element open tag
- .prepend
- change an elements ID Name
- .attr('attr-new-id', 'new-id')
- .attr('id', 'prop-new-id')'
- Execute code on a click event:
- $(#a-button').on('click,fuction(){
- cosole.log('button clicked');
- })'
- $(#a-button').click(fuction(){
- cosole.log('button clicked');
- });
- Form Element Selectors
- :checkbox
- :input
- :focus
- :selected
- :submit
- The .val() method allows you get or set the value entered into a form element:
- // Get the text string currently entered into the input:
- $('input:text').val();
- // Set a new value for the input by passing in a string:
- $('input:text').val('A new value');
- // Clear out an input by passing empty quotes into .val():
- $('input:text').val('');
- Email validation
- <form id="my-form">
- <input type="email" id="my-text-input" />
- <input type="submit" />
- </form>
- $('#my-form').on('submit', function(event) {
- event.preventDefault();
- if ( $('#my-text-input').val() == '' ) {
- alert('You missed the field.');
- } else {
- alert('Thanks for filling the field!');
- }
- });
- $('.add-to-cart').click('button', function(event) {
- event.preventDefault();
- var cartCount = parseInt($('.count').html(), 10);
- $('.count').html(cartCount +=1);
- // .count = (.count + cartCount);
- // $('.add-to-cart').add(cartCount += 1);
Add Comment
Please, Sign In to add comment