Exam Study Flashcards

1
Q
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?
A

$(“div”);
$(“.ghost”);
$(“#boats”);
$(“TD .tk”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you create a function in JavaScript?

A
10.	function func(a, b){
if (a > b)
	return true;
else
	return false;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you use a script tag to open and run a JavaScript file ?

A

“”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you setup a mouse over event inside an HTML element?

A

“<p></p>”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you setup a mouse hover using raw js?

A

document.getElementById(“para”).mouseover = function() { console.log(‘moo’) };

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you setup a mouse over event in jQuery?

A

$(“#para”).mouseEnter(function() { console.log(‘moo’) });

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you change the value of an input element in raw js?

A

document.getElementById(“mytext”).value = “JS is Cool”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you change the value of an input element using jQuery

A

$(“#mytext”).val(“JS is Cool”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you make an element disapear after 5 seconds without using fade out in jQuery?

A

$(“#bigmenu”).delay(5000).hide();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you remove the last item in the header section using jQuery?

A

$(“head”).last().remove();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you add an empty div container to the end of the body in jquery?

A

$(“body”).prepend().html(“<div></div>”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you change the colour of an element by Id in raw js?

A

document.getElementById(“bean”).style.color = “orange”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you change the colour of an element by I’d in jQuery

A

$(“#bean”).css(“color”, “orange”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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”?

A
var results = document.querySelectorAll(“td .tk”);
for (i = 0; i < results.length; i++) { results[i].innerHTML = “taken”}

Vs

$(“TD .tk”).html(“taken”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you use the windows load event listener?

A

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)+ “)”;
}
});

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the push Ajax call look like?

A
var text = $("#topic").val();
            $.ajax({
               url:"response.php",
               method:"GET",
               data:{topic:text},
               dataType:"text",
               success:function(data){
                   $("body").append().html("<p>" + data +       “</p>”);
               }
        });
17
Q

What does the pull Ajax call look like from a php echo?

A
$command = "SELECT `tweet` FROM `tbl_tweet` ORDER BY `tweet_id` DESC";
$query = $dbh->prepare($command);
$result = $query->execute();
$json_array = array();
while ($row = $query->fetch()) {
    $json_array[] = $row;
}
// set the header and echo out the encoded json data
header('Content-type: application/json');
echo json_encode($json_array);
—————————————————-
$.ajax({  url:"fetch.php",
               method:"POST",
               dataType:"json",
               success:function(data){...});
18
Q

How do you create a button click event in js?

A

$(“#thebutton”).click(function(){ … }