Skip to content

Commit 778ba91

Browse files
committed
added jQuery exercises .js
1 parent 9354019 commit 778ba91

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

jQueryPart1.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
if($.isReady) {
2+
console.log(".isReady says the DOM is ready! To party!")
3+
} else {
4+
console.log('.isNotReady :(')}
5+
document.addEventListener('DOMContentLoaded', function() {
6+
console.log("Let's get ready to party with vanilla JS!")
7+
})
8+
$(console.log("The DOM is ready. Let's get ready to party with jQuery!"))
9+
10+
$('article').attr('class', 'image-center');
11+
// $('article').addClass('image-center');
12+
13+
$('p').eq('5').remove();
14+
// $('article p:lastChild').remove();
15+
16+
$('#title').css('font-size', Math.random()*100);
17+
18+
$('ol').append('<li>Whatever you want</li>');
19+
20+
$('aside').html("").append('<p>This is a long and lengthy and wordy and, perhaps even, verbose paragraph prepared as an apology for the former, and now removed, list of thoughts, which once resided in this position.</p>');
21+
22+
$('input.form-control').on("change click keyup", function() {
23+
let $red = $('input.form-control').eq(0).val();
24+
let $green = $('input.form-control').eq(1).val();
25+
let $blue = $('input.form-control').eq(2).val();
26+
27+
$('body').css('background-color', `rgb(${$red}, ${$green}, ${$blue})`)
28+
})
29+
30+
$('img').on('click', function(){
31+
$(this).remove()
32+
});

jQueryPart2.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
$('#subBttn').on('click', function() {
2+
let title = $('#titleInput').val();
3+
let rating = $('#ratingInput').val();
4+
5+
if(title.length < 2 || !(0 <= rating && rating <= 10 )){
6+
alert('Title must be at least two characters in length and rating must be between 0-10')
7+
}
8+
else {
9+
let $movie = $(`<li>Title: ${title} <br> Rating: ${rating}</li>`)
10+
let $delBttn = $(`<br><button id="delBttn">Delete</button>`)
11+
12+
$($movie).append($delBttn);
13+
$('#movieList').append($movie);
14+
}
15+
$('#movieList').on('click', '#delBttn', function() {
16+
console.log(this)
17+
$(this).parent().remove();
18+
})
19+
})
20+
21+
22+

0 commit comments

Comments
 (0)