Help with JavaScript and JQuery Review the HTML for the application, and notice
ID: 3817409 • Letter: H
Question
Help with JavaScript and JQuery
Review the HTML for the application, and notice that it contains an img element with an id of “image” following the heading. Also notice that the href attributes of the <a> elements in the carousel are set to the URL of the enlarged image to be displayed when the associated carousel image is clicked.
1.Code an event handler for the click event of the <a> elements in the list. This event handler should start by getting the URL for the image to be displayed. Then, it should assign this URL to the enlarged image.
2. Add animation to the click event handler so the opacity of the current image is set to 0 and 205 is subtracted from the left margin of the image over a period of 1 second. Use a callback function to reverse this animation. This function should also contain the statement that sets the URL for the enlarged image. The effect will be for the current image to fade out as it slides to the left, and then for the new image to fade in as it slides to the right.
HTML file:
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Carousel Animation</title>
<link rel="stylesheet" href="main.css">
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="carousel.js"></script>
</head>
<body>
<main>
<h1>View our Books</h1>
<img id="image" src="images/book1.jpg" alt="SQL Server 2008 for Developers">
<div id="carousel">
<div id="left_button" class="button_panel"><img src="images/left.jpg" alt=""></div>
<div id="display_panel">
<ul id="image_list">
<li><a href="images/book1.jpg"><img src="images/book1.jpg" alt="SQL Server 2008 for Developers"></a></li>
<li><a href="images/book2.jpg"><img src="images/book2.jpg" alt="PHP and MySQL"></a></li>
<li><a href="images/book3.jpg"><img src="images/book3.jpg" alt="Visual Basic 2010"></a></li>
<li><a href="images/book4.jpg"><img src="images/book4.jpg" alt="ADO.NET 4 database programming with VB 2010"></a></li>
<li><a href="images/book5.jpg"><img src="images/book5.jpg" alt="ASP.NET 4 web programming with VB 2010"></a></li>
<li><a href="images/book6.jpg"><img src="images/book6.jpg" alt="Oracle SQL and PL/SQL"></a></li>
<li><a href="images/book7.jpg"><img src="images/book7.jpg" alt="Java Servlets and JSP"></a></li>
<li><a href="images/book8.jpg"><img src="images/book8.jpg" alt="C# 2010"></a></li>
<li><a href="images/book9.jpg"><img src="images/book9.jpg" alt="ASP.NET 4 web programming with C# 2010"></a></li>
</ul>
</div>
<div id="right_button" class="button_panel"><img src="images/right.jpg" alt=""></div>
</div>
</main>
</body>
</html>
CSS file:
* {
margin: 0;
padding: 0;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 85%;
margin: 0 auto;
width: 410px;
height: 480px;
padding: 20px 0;
border: 2px solid blue;
}
h1 {
font-size: 140%;
text-align: center;
margin-bottom: .5em;
}
#image {
height: 250px;
margin-bottom: 1em;
margin-left: 105px;
}
/* the styles for the carousel */
.button_panel {
height: 125px;
padding: 50px 15px;
float: left;
}
.button_panel img {
width: 25px;
height: 25px;
}
#display_panel {
width: 300px;
overflow: hidden;
float: left;
height: 125px;
}
#image_list {
position: relative;
left: 0px;
width: 900px;
list-style: none;
}
#image_list li {
float: left;
width: 100px;
}
#image_list li img {
width: 95px;
}
JavaScript file
$(document).ready(function() {
var slider = $("#image_list"); // slider = ul element
var leftProperty, newleftProperty;
// the click event handler for the right button
$("#right_button").click(function() {
// get value of current left property
leftProperty = parseInt(slider.css("left"));
// determine new value of left property
if (leftProperty - 300 <= -900) {
newLeftProperty = 0; }
else {
newLeftProperty = leftProperty - 300; }
// use the animate function to change the left property
slider.animate( {left: newLeftProperty}, 1000);
}); // end click
// the click event handler for the left button
$("#left_button").click(function() {
// get value of current right property
leftProperty = parseInt(slider.css("left"));
// determine new value of left property
if (leftProperty < 0) {
newLeftProperty = leftProperty + 300;
}
else {
newLeftProperty = 0;
}
// use the animate function to change the left property
slider.animate( {left: newLeftProperty}, 1000);
}); // end click
}); // end ready
Explanation / Answer
.ORIG x3000
LD R3, POSASC ;Loads R3 with #48
LD R4, NEGASC
LD R1, word ;R1 = word
Include R6, R6, #5 ;Length of word
GETC ;Gets the burn
OUT ;Prints the burn
Include R2, R2, R0 ;Stores the burn in R2
;Include R2, R2, R4 ;To ascii
What's more, R0, R0, #0 ;set R0 back to 0
Circle
Furthermore, R5, R2, R1 ;check if singe is equivalent
Include R1, R1, #1 ;augmentation to next singe in word
Include R6, R6, #-1
BRnp LOOP
Include R0, R0, R5 ;Set R0 to # of events
OUT ;Print # of events
End
POSASC .FILL x0030 ;#48
word .STRINGZ "hi" ;word to tally events of a roast
NEGASC .FILL xFFD0 ;#-48
.END
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.