Exam Study Flashcards
How do you select an element How do you choose a class How do you choose an Id How do you choose a class inside a certain element All with a selector in jQuery?
$(“div”);
$(“.ghost”);
$(“#boats”);
$(“TD .tk”);
How do you create a function in JavaScript?
10. function func(a, b){ if (a > b) return true; else return false; }
How do you use a script tag to open and run a JavaScript file ?
“”
How do you setup a mouse over event inside an HTML element?
“<p></p>”
How do you setup a mouse hover using raw js?
document.getElementById(“para”).mouseover = function() { console.log(‘moo’) };
How do you setup a mouse over event in jQuery?
$(“#para”).mouseEnter(function() { console.log(‘moo’) });
How do you change the value of an input element in raw js?
document.getElementById(“mytext”).value = “JS is Cool”;
How do you change the value of an input element using jQuery
$(“#mytext”).val(“JS is Cool”);
How do you make an element disapear after 5 seconds without using fade out in jQuery?
$(“#bigmenu”).delay(5000).hide();
How do you remove the last item in the header section using jQuery?
$(“head”).last().remove();
How do you add an empty div container to the end of the body in jquery?
$(“body”).prepend().html(“<div></div>”);
How do you change the colour of an element by Id in raw js?
document.getElementById(“bean”).style.color = “orange”;
How do you change the colour of an element by I’d in jQuery
$(“#bean”).css(“color”, “orange”);
What is the difference between the code of raw js and jQuery when trying to change all the elements inner HTML of a div container to “taken”?
var results = document.querySelectorAll(“td .tk”); for (i = 0; i < results.length; i++) { results[i].innerHTML = “taken”}
Vs
$(“TD .tk”).html(“taken”);
How do you use the windows load event listener?
Window.addEventListener(‘load’, function() {
Document.getElementById(“colorbox”).mouseover = function() {
Document.getElementById(“colorbox”.style.backgroundColor =
“rgb(“ + Math.floor(Math.random()256)+ “,”
+ Math.floor(Math.random()256)+ “,”
+ Math.floor(Math.random()*256)+ “)”;
}
});