Hello! I would greatly appreciate if someone could lend me a hand with this Java
ID: 3712854 • Letter: H
Question
Hello! I would greatly appreciate if someone could lend me a hand with this JavaScript assignment. I have been looking at it for a while now, and I am honestly not sure exactly what the professor might want.... this is all the information i have about this assignment:
JQuery
Take the following HTML:
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-git.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Set the background color green of the page elements using jQuery.</title>
<style type="text/css">
button {
display: block;
margin: 20px 0 0 0;
} </style>
</head>
<body>
<textarea>Understanding JQuery using real examples</textarea>
<p>jQuery</p>
<span>Real Examples</span>
<button id="button1">Click to see the Result</button>
</body>
</html>
Write the needed JQuery that captures a click event and turns the background color to green. Used Methods :
.add(elements) : Create a new jQuery object with elements added to the set of matched elements. Here .add() method adds more elements like "span", "textarea" etc.
.css(propertyName) : Get the computed style properties for the first element in the set of matched elements.
Hint: $('#buttonName').click(function(){
$("p").add( "span" ).add("textarea").css( "background", "red" );
});
Use Ajax to replace the text “ Change content” with your name. Here is the provided code that needs to be corrected:
<!DOCTYPE html>
<html>
<body>
<div id="affectedText">
<h1>The XMLHttpRequest Object</h1>
<button type="button">Change Content</button>
</div>
<script>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML =
"TESTING";
}
};
xhttp.open("GET", "ajax_info.txt", true);
xhttp.send();
}
</script>
</body>
</html>
Thanks!!
Explanation / Answer
<!DOCTYPE html>
<html>
<head>
<script type="text/JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" ></script>
<script>
function loadDoc() {
$('#button').text('Your Name here');
$('body').css('background-color','green');
}
</script>
</head>
<body>
<div id="affectedText">
<h1>The XMLHttpRequest Object</h1>
<button type="button" id="button">Change Content</button>
</div>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.