The hover() method takes two functions SEPERATED BY A COMMA and is a combination of the mouseenter() and mouseleave() methods.
The first function is an alert saying "You entered" is executed when the mouse enters the HTML element
The second function is an alert saying "You now leave" is executed when the mouse leaves the HTML element:
Front
$("xxx").hover(function(){
alert("You entered");
},
function(){
alert("You now leave");
});
Back
Attach multiple (3) event handlers to a <p> element
When the "button" element is clicked change 2 attributes of an element with an id of "xxx": First, change "href" attribute to "abc.com". Then, change the "title" attribute to "new title"
When the "button" element is clicked run a function chaining 3 actions: First change text color to red. Second, make element slide up in 2000 ms. Third, make the element slide down in 2000 ms.
When the "button" element is clicked run a function that is an alert saying whatever the value of the "href" attribute that is connected to an element with the id of "xxx"
The example below has a callback parameter that is a function that will be executed after the hide effect is completed:
Front
$("button").click(function(){
$("p").hide("slow", function(){
alert("The paragraph is now hidden");
});
});
Back
Section 3
(7 cards)
when attempting to edit a vlue of something , when do you use the html() method and the .val method
Front
.html() can be used to set the contents of the first element match it finds. For instance,
.val() is used to get the value of form elements. For example,
$('input:checkbox:checked').val();
Back
what does the toggleClass do
Front
used to swtich elements on and off
Back
how do you select mulitple things in one selector
Front
$('p, li').fadeTo('slow', 0);
Back
what should all javascript be encapsulated in?
Front
$(document).ready(function(){
});
Back
how do you get the value from an input with a name
Front
$('input[name=checkListItem]').val();
Back
what are two html elements that can receive focus
Front
<textarea>s and <input>
Back
what is the .on() method and what does it do?
Front
a general handler that takes the event, its selector, and an action as inputs. The syntax looks like this:
$(document).on('event', 'selector', function() {
Do something!
});