Skip to content

Instantly share code, notes, and snippets.

@traineed
Created December 3, 2011 13:58
Show Gist options
  • Select an option

  • Save traineed/1427189 to your computer and use it in GitHub Desktop.

Select an option

Save traineed/1427189 to your computer and use it in GitHub Desktop.
jQuery Examples
$('p').css('font-size'); //Manipulates CSS
$('p:first').toggleClass('bigger'); // Adds & removes Class Bigger
$('p:first').hide();
$('p:first').show();
$('p:first').toggle(); // toggles between Hide and Show
$('p').text('abcd'); //Strips HTML
$('p').html('<b>abc</b>'); //includes HTML
$('p').prepend('abcd'); //Adds to start of p
$('p').append('abcd'); //Adds to start end p
$('p').before('<h1>abcd<h1>'); //Adds sibling before selection
$('p').after('<i>abcd<i>'); //Adds sibling after selection
$('p:first').remove(); // removes object from the DOM
@traineed
Copy link
Copy Markdown
Author

traineed commented Dec 3, 2011

function
.text >> without parameter query the plain text / with parameter set the plain text
.html >> without parameter query html and text / with parameter set html and text
.prepend >> add element inside the beginning of the selectionadd element inside the beginning of the selection
.append >> add element inside the end of the selectionadd element inside the end of the selection
.before >> add element before selectionadd element before selection
.after >> add element after selectionadd element after selection
.remove >> remove element from the DOM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment