jQuery Flashcards
DOM
Document Object Model - a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents.
How to link a JavaScript script to an html file?
In head:
script type=’text/javascript’ src=’script.js’
Basic jQuery syntax
$(document).ready(function () {
});
Creating a variable
var $target = $(‘div ol li li’);
this keyword
affects only the element that triggered the event handler
Syntax: .css() [use]
$(“div”).css(“background-color”,”red’); [changes (/adds?)the css properties of an element]
.html(), .val() [uses]
html gets [.html()] or changes [.html(‘hi’)] the contents of a tag. val gets the contents of form elements
Syntax: getting a value from a form
var $toAdd = $(‘input[name=name_of_form]’).val();
.on()
$(document).on(‘event’,’selector’, function() {
Do stuff;
});
Syntax: .animate()
$(‘div’).animate({left:’-=50px’}, 200)
Syntax: taking an input for, e.g. .keydown()
$(document).keydown(function(key) { // key is the key })
jQuery UI
script src=”//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js” /script