Skip to content
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
6 changes: 3 additions & 3 deletions 1-0/script.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
$(documnt).ready(function {
alert("congratulations, you fixed it!');
});
$(document).ready(function() {
alert("congratulations, you fixed it!");
});
8 changes: 4 additions & 4 deletions 2-0/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ $(document).ready(function() {
}
];
for (var i = 0; i<data.length; i++) {
if (data.text) {
$('#news').append("<p><button type='button' class='btn btn-default' data-href='"+data.href+"''><span class='glyphicon glyphicon-star'></span> "+data.text+"</button></p>");
if (data[i].text) {
$('#news').append("<p><button type='button' class='btn btn-default' data-href='"+data[i].href+"''><span class='glyphicon glyphicon-star'></span> "+data[i].text+"</button></p>");
}
}
$("button").click(function() {
if (!this.attr('data-href')) {
document.location = this.attr('data-href');
if (!$("button").attr('data-href')) {
document.location = $("button").attr('data-href');
}
});
});
5 changes: 3 additions & 2 deletions 2-1/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ $._get = function(url, callback) {
})
}


$(document).ready(function() {
var masterLocation;
var search_term = 'devmountain';
function setupApi() {
var masterLocation = 'http://devmounta.in?q='+search_term;
masterLocation = 'http://devmounta.in?q='+search_term;
$(document).ajaxError(function(e, xhr, settings, thrown) {
console.log("Ajax ERROR", xhr, settings, thrown);
})
}
setupApi();
$._get(masterLocation, function(data) {
$.each(data.results, function(index, tweet) {
$('#results').append('<p><span class="glyphicon glyphicon-thumbs-up"></span> '+this.tweet+'</p>');
$('#results').append('<p><span class="glyphicon glyphicon-thumbs-up"></span> '+tweet+'</p>');
});
});
});
4 changes: 2 additions & 2 deletions 3-0/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
</head>
<body>
<div class="container">
<div class="container" id="container">
<div class="hero-unit">
<h1>Javascript Debugging Exercise 3-0</h1>
<p class="text-danger">Find and fix the jQuery errors.</p>
<p class="text-info">When complete, you should be able to click each list item and have its number to the right decrease until 0, at which point it disappears.</p>
</div>
<div>
<h4>Click the list items until they reach 0 in number</h4>
<ul class="list-group">
<ul class="list-group" id="items">
<li class="list-group-item">
<span class="badge">4</span>
Cras justo odio
Expand Down
8 changes: 4 additions & 4 deletions 3-0/script.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
$(document).ready(function() {
$('.list-group-items').click(function() {
$(this).find('span', function(span) {
var num = Number($(this).html());
$('.list-group-item').click(function() {
$(this).each(function(span) {
var num = Number($(this).find('span').html());
num--;
if (num <= 0) {
num = '';
}
$(this).html = num;
$(this).find('span').html(num);
})
});
});