Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jQuery DOM manipulation #133

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!doctype html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.js" integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" crossorigin="anonymous"></script>
<script src="script.js"></script>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
Expand Down Expand Up @@ -55,4 +56,4 @@ <h3>

</body>

</html>
</html>
33 changes: 33 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
$(document).ready(() => {
//Change the <h1> to something cheeky
$('h1').html('something cheeky');

//create ordered list and list items
$list = $('<ol></ol>')
.append($('<li>Traversal #1 to parent</li>'))
.append($('<li>Traversal #2 to children</li>'))
.append($('<li>Traversal #3 to siblings</li>)'));

//add list to container
$('h4').parent().append($list);
//center list
$('.info-box').css({
textAlign: 'center',
listStyle: 'inside'
});

//sad classes become happy
$('.sad').addClass('happy').removeClass('sad');

//annoying popup link and location changed
$('#annoying-popup')
.attr('href', 'http://www.cashcats.biz')
.css({'top': '30px', 'right': '0'});

/*Replace the ellipsis ... in one of the suggested topics with the content
of your choice -- but do so by traversing from a different element.*/
$('ul').children().last().prev().html('Various variables');

//Replace the form input with a <textarea> instead of a <input type="text">.
$('input[type="text"]').replaceWith('<textarea></textarea>');
});