Skip to content

Commit

Permalink
added jQuery exercises .js
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjones320 committed Dec 30, 2023
1 parent 9354019 commit 778ba91
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
32 changes: 32 additions & 0 deletions jQueryPart1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
if($.isReady) {
console.log(".isReady says the DOM is ready! To party!")
} else {
console.log('.isNotReady :(')}
document.addEventListener('DOMContentLoaded', function() {
console.log("Let's get ready to party with vanilla JS!")
})
$(console.log("The DOM is ready. Let's get ready to party with jQuery!"))

$('article').attr('class', 'image-center');
// $('article').addClass('image-center');

$('p').eq('5').remove();
// $('article p:lastChild').remove();

$('#title').css('font-size', Math.random()*100);

$('ol').append('<li>Whatever you want</li>');

$('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>');

$('input.form-control').on("change click keyup", function() {
let $red = $('input.form-control').eq(0).val();
let $green = $('input.form-control').eq(1).val();
let $blue = $('input.form-control').eq(2).val();

$('body').css('background-color', `rgb(${$red}, ${$green}, ${$blue})`)
})

$('img').on('click', function(){
$(this).remove()
});
22 changes: 22 additions & 0 deletions jQueryPart2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
$('#subBttn').on('click', function() {
let title = $('#titleInput').val();
let rating = $('#ratingInput').val();

if(title.length < 2 || !(0 <= rating && rating <= 10 )){
alert('Title must be at least two characters in length and rating must be between 0-10')
}
else {
let $movie = $(`<li>Title: ${title} <br> Rating: ${rating}</li>`)
let $delBttn = $(`<br><button id="delBttn">Delete</button>`)

$($movie).append($delBttn);
$('#movieList').append($movie);
}
$('#movieList').on('click', '#delBttn', function() {
console.log(this)
$(this).parent().remove();
})
})



0 comments on commit 778ba91

Please sign in to comment.