Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added CS joke button and box#2

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
diyathangada wants to merge5 commits intosolygambas:masterfromdiyathangada:master
Closed
Changes fromall 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
25 changes: 25 additions & 0 deletions010-dad jokes/index.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,5 +13,30 @@ <h3>Don't Laugh Challenge</h3>
<button id="jokeBtn" class="btn">Get Another Joke</button>
</div>
<script src="script.js"></script>
<br><br><br>
<div id="container2" class="container">
<h3>Don't Laugh Challenge: Computer Science Edition</h3>
<div id="csJoke" class="joke">Click the button for a Computer Science joke!</div>
<button id="csJokeBtn" class="btn" onclick="generateCSJoke();">Get Another Joke</button>
</div>
<script language="JavaScript">
var jokes = ["What did the hungry computer scientist do? Get a byte to eat!",
"What are programmers favorite animal? A boo-lion!",
"What is a software engineers favorite drink? Java chip frappe!",
"Why couldn't the student use GitHub? They couldn't commit."];

function generateCSJoke(){
var removeJoke = document.getElementById("csJoke");
document.getElementById('container2').removeChild(removeJoke);
var i = parseInt(Math.random() * jokes.length);
const jokeDiv = document.createElement("div");
jokeDiv.setAttribute("id", "csJoke");
jokeDiv.setAttribute("class", "joke");
const jokeContent = document.createTextNode(jokes[i]);
jokeDiv.appendChild(jokeContent);
var csJokeButton = document.getElementById("csJokeBtn");
document.getElementById('container2').insertBefore(jokeDiv, csJokeButton);
}
</script>
</body>
</html>

[8]ページ先頭

©2009-2025 Movatter.jp