1. (4 points) For any small Javascript task, give the syntax for doing it normal
ID: 3917264 • Letter: 1
Question
1. (4 points) For any small Javascript task, give the syntax for doing it normally and then give an example of how jQuery makes that task easier to code. (Can just be one or two lines of code each)
2. (4 points) What is the difference in Javascript between declaring a variable that will hold an integer and a variable that will hold a string?
3. (4 points) Provide the single line of code that would be required to pop up an alert to the user and make the contents of the alert the 4th element of an array called 'warnings'
4. (4 points) Show the jQuery selector syntax that would select all elements on the page of class 'warnings' and make them hidden.
5. (4 points) Show the jQuery syntax for saving the value of a form element with id 'codon' into a variable called 'codonVal'.
Explanation / Answer
Please Note: As per Chegg Answering Guidelines, I have answered the first question. Please Post Separate for Separate Questions.
Q1) Answer)
Javascript is a scripting language and JQuery is the library or a framework built on the Javascript to support scripting. Thus JQuery is a Javascript library and makes it easier to write scripts than using plain and simple Javascript.
For example, suppose for an element such as a button which is called as value is Submit, id also submit.
The JavaScript code for the button would be:
document.getElementById(submit)
.addEventListener('click', function(){
alert("Submitted");
});
The jQuery version of the same problem would be shorter and simpler as:
$('#submit').click(function(){
alert("Submitted");
});
Thus we can see that jQuery is simpler and shorter and more understandable than Javascript, and is more efficient.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.