Student's Name | Ali Shariati
Course | Scripting Language II (LS2)
Exam Type | Mid-term
What to Do | Considering the questions you have been given in the PDF file, create an interactive answer sheet as you write the answers, using JQuery.
Java and JavaScript are the same language?(True/False)
False, Jquery is not even a programming language rather a cross-platform JS library.
A programmer should never re-use existing code.(True/False)
False. Weird question!
Briefly explain what is the purpose of JQuery?
What symbol is used to identify JQuery code?
$
What is the following jQuery instruction used for?
$(document).ready(function(){ ... });
Scripts are read from top to buttom. this event acts like a signal. When reading a source code, it signals the code inside i is ready and can be execute it without being worry about the te parts tat are not created. In other words, it makes the funciton availabe after the page is loaded. So with this event it no longer matters where to put the script,at the top or the bottom othe source code
What does the acronym DOM stand for?
Briefly explain what actually is the DOM?
What would the following jQuery instruction do?
$("#myElement");Hover on the text area once, to see more ...
It selects the one html element that has the id of "myElement".
What would happen if you would click the button from the code below?
<h1>Test 3</h1> <button id="test3">Click here <script type="text/javascript"> $("#test3").click(function() { $("h1").css("color", "red"); });
It changes the Test 3 heading 1 color to red
Which Paragraph will have the new text when you click the button?
<button>Replace existing content <p>This is paragraph #1</p> <p>This is paragraph #2</p> <script> $("button").click(function(){ $("p");html("<h1>Hello world!"); }); </script>
Technically nothing! because there is a syntax error: after selecting p element, html method has been added with a semi-colon (;); whereas is should have been added with a dot (.).But, if we fix it, it will replace the two paragraphs with the "Hello World!" header h1
Which of these are mouse events in JQuery?
All of them!
The AJAX request “load()” retrieves the entire content of the file. (True/False)
JSON is a human readable format for structuring data. (True/False)
False, it's machine readable
Which of the followings is the correct format for a Key/Value pair in JSON?
This one is a really weird question! As far as I know my keyboard only generates one form of double quotes in code editors: "key" : "value". So I guess the answer is (e) or (d)?!
Elements of JSON's objects can be:
(e)
Explain in detail what the following code would do?
<h1> <script> $.getJSON('http://www.server.com/myExam.json', function (data) { $("h1").append("You are " + data.age + " years old."); }); </script>
If there is no time out or not found error, and the status is successful, the used method (geJASON) gets the age key value of the jason file which is in the above URL, and then displays it by appending it into the header 1 element followed by some text.