There are several options for using jquery
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
Pass the $ function CSS style selectors to serch for things. What is returned is an jquery style array thingy filled with jQuery objects.
$('#special')
$('.navbutton')
$('img')
$('div.imgholder p:nth-child(2)')
When you have a jQuery object you use.css to set the style of that object. You don't have to relearn css just use the styles as written.
Assume: var $par = $('p');
obj.css("css property", "setting")
$par.css("background-color", "blue");
obj.css({
cssProperty : "setting",
cssProperty2 : "setting2",
...
});
obj.css({
"background-color" : "blue",
"font-family" : "sans-serif",
"font-weight" : "bold"
});
Simple as pie useing .attr() function.
Assume: var $img = $('img');
$img.attr("src", "snowflake.jpg");
$img.attr({
"src" : "snowflake.jpg",
"alt" : "snow is falling",
"title" : "I love snowflakes"
});
All about the $ function. Surround the tag name with < and >.
var img = $("<img>");
var img = $('<img>', {
"src" : "snowflake.jpg",
"alt" : "snow is falling",
"title" : "I love snowflakes"
});
Use the .remove()
method.
$("#bestName").remove();
$('p').fadeOut('slow', function() { $(this).remove(); })