function findUser(data) { .....; $getJSON (URL, findData()) ) // declared findUser, calling findData
function findData (data) { ... $getJSON (URL, pushHTML()) } // declared findData, calling pushHTML()
function pushHTML(data) { ... } // declared pushHTML()
$(document).ready $(document).ready(
function(){ ... for(i=0;i<array;i++) { //the array contains different URL
$getJSON(array[i], findUser())
}
}
// what I expect: documentReady --> findUser --> findData --> pushHTML --> loop
// what happened: it loops, but all the content being pushed to the HTML is the same, data from the second last data I wanted to find in that array... why????
max77p sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 695 | @gregatgit |http://www.freecodecamp.com/gregatgit
function buildHtml(img, class, address){
var myHtml = '<div class="' + class + '">';
myHtml += <a href="' + address // and keep building it
$("#channels").append(myHtml);
}
if (json.hasOwnProperty('error')
check for errors (do nothing but console it if its there are there 'else if' check if(json.data === null)
- now you know its offline - 'else' - its online
supernerd1 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 696 | @gregatgit |http://www.freecodecamp.com/gregatgit
myFunction(str){
var greeting = "Hi " + str + "!";
return greeting;
}
How can I add links to my portfolio? I tried going back in the previous lessons but couldn't find an answer
'User Story: I can click different buttons that will take me to the portfolio creator's different social media pages.'
"Navigate to different sections of the webpage by clicking buttons in the navigation."
^how can I complete that?
max77p sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 697 | @gregatgit |http://www.freecodecamp.com/gregatgit
body {
background: url("your img url")no-repeat center fixed;
background-size: cover;
text-align: center;
}
sorry anukath, you can't send brownie points to yourself! :sparkles: :sparkles:
<blockquote>
in bootstrap. When using bootstrap, it will automatically give you a border-left. you can combat this by creating border: none;
for your blockquote.
$('div[id^=par]').removeClass('bord');
I would also change the color when hovering to be different from the green one(active) in the bord class
.parag:hover{}
to.parag:not(.bord):hover{}
blackhat144 sends brownie points to @jwoo92 :sparkles: :thumbsup: :sparkles:
:cookie: 390 | @jwoo92 |http://www.freecodecamp.com/jwoo92
:bulb: to format code use backticks! ``` more info
<div data-sticky-container>
<div class="title-bar" data-sticky data-options="marginTop:0;stickyOn:small" style="width:100%;" data-responsive-toggle="example-menu" data-hide-for="medium">
<button class="menu-icon" type="button" data-toggle></button>
<div class="title-bar-title">
pyxis
</div>
</div>
<div class="top-bar" id="example-menu" data-sticky data-options="marginTop:0;stickyOn:small" style="width:100%;">
<div>
<div class="top-bar-right">
<ul class="dropdown menu" data-dropdown-menu>
<li class="menu-text">pyxis</li>
<li><a href="#about">about</a></li>
<li><a href="#portfolio">portfolio</a></li>
<li><a href="#contact">contact</a></li>
</ul>
</div>
</div>
</div>
</div>
:bulb: to format code use backticks! ``` more info
shivam13 sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
:cookie: 502 | @sorinr |http://www.freecodecamp.com/sorinr
d1sr3 sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
:cookie: 503 | @sorinr |http://www.freecodecamp.com/sorinr
Hello I'm working with the twitch api and I might not get closed stream json :
$.ajax({
dataType: 'json',
type: 'GET',
url: 'https://api.twitch.tv/kraken/streams/brunofin',
success: function(response) {
console.log(response);
}
});
When I'm trying to do it with a normal unclosed stream I have no problems
promhize sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
:cookie: 504 | @sorinr |http://www.freecodecamp.com/sorinr
$.each(streams, function (key,value) {{...
and url: 'https://api.twitch.tv/kraken/streams/' + streams[key],
Hi guys, why in Firefox it doesn't work? ReferenceError: event is not defined
function createBoard() {
for (var i = 0; i < n; i++) {
board_array[i] = new Array(n);
for (var j = 0; j < n; j++) {
var tile = document.createElement("div");
tile.setAttribute("id", j + "-" + i);
tile.onmousedown = function() {clickField(this, event);}; // THIS
document.getElementById("board").appendChild(tile);
board_array[i][j] = 0;
}
}
}
How can I do that? Thanks.
d1sr3 sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
:cookie: 505 | @sorinr |http://www.freecodecamp.com/sorinr
<button type="submit" class="pure-button pure-input-1-2 pure-button-primary">Sign in</button>
.bt{float:right;}
?
```<a class="current hvr-underline-from-center" href="#0"> Home </a>
.hvr-underline-from-center {
<form class="pure-form">
<fieldset class="pure-group">
<input type="text" class="pure-input-1-2" placeholder="Username">
<input type="text" class="pure-input-1-2" placeholder="Password">
<input type="email" class="pure-input-1-2" placeholder="Email">
</fieldset>
<fieldset class="pure-group">
<input type="text" class="pure-input-1-2" placeholder="A title">
<textarea class="pure-input-1-2" placeholder="Textareas work too"></textarea>
</fieldset>
<button type="submit" class="pure-button pure-input-1-2 pure-button-primary">Sign in</button>
</form>
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css">
evandcp sends brownie points to @carlosferrerceldran :sparkles: :thumbsup: :sparkles:
:cookie: 121 | @carlosferrerceldran |http://www.freecodecamp.com/carlosferrerceldran
hello, please help me to make imacro to click dynamic generate link.
need to click that link via imacro.
<div class="title" id="title-33">
<span itemprop="name">
<h2>
<a href="/story.php?id=33">Pahasu.lk | Free Classifieds Ads Sri lanka.</a>
</h2>
</span>
Thanks
evandcp sends brownie points to @ericbezanson :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @ericbezanson |http://www.freecodecamp.com/ericbezanson
to find the mistake in my code
return myObj[checkProp]
should work.
@cysonya var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice = Math.random(0, 0.33)) { computerChoice = "rock";
} else if (computerChoice = Math.random(0.34, 0.66)) {
computerChoice = "paper";
} else (computerChoice = Math.random(0.67, 1)){
computerChoice = "scissors";
}
hoxtygen sends brownie points to @cysonya :sparkles: :thumbsup: :sparkles:
:cookie: 329 | @cysonya |http://www.freecodecamp.com/cysonya
mor1990 sends brownie points to @benalron :sparkles: :thumbsup: :sparkles:
:cookie: 393 | @benalron |http://www.freecodecamp.com/benalron
mor1990 sends brownie points to @benalron :sparkles: :thumbsup: :sparkles:
:warning: mor1990 already gave benalron points
Hello everyone. I was trying to make my background change on button click but it changes only one time. Any suggestions what it wrong in my JS code?
function removeBackground() {
"use strict";
var newColor = document.getElementsByTagName('p');
var url1 = "url('http://saunders1865.com/wp-content/uploads/2014/10/poppy.jpg')";
var url2 = "url('http://wallpapercave.com/wp/w9yJH4s.jpg')";
function changeImage() {
var temp = document.getElementsByClassName('demo-layout-transparent')[0];
var newImage = temp.style.backgroundImage;
if (newImage == url1) {
newImage = url2;
} else {
newImage = url1;
console.log('url1 ', url1);
console.log('newImage = ', newImage);
}
temp.style.backgroundImage = newImage;
}
changeImage();
for (let i = 0; i < newColor.length; i += 1) {
newColor[i].style.color = "blue";
}
}
a link to the page on the codepen is http://codepen.io/Y-Taras/pen/rLJPxd
:warning: could not find receiver for bhushan933
y-taras sends brownie points to @bhushan933 :sparkles: :thumbsup: :sparkles:
http://ip-api.com/json
which is by IP address an less accurate but enough so for the project
React
I put in the JS window isn't creating an h2
elem at the top center of my pen? I'm just learning Reactborder:none;
for the quote
class getting rid of the white smear on the left end of the green border for the first quote? Yesterday, I had the same problem, and fixed it with the aforementioned CSS- what am I doing this time that makes it not work?
$('social-content')
this needs a . or # for class or id -
cjrutherford sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2018 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
$(document).load()
instead of $(document).ready()
blackhat144 sends brownie points to @steedler :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @steedler |http://www.freecodecamp.com/steedler
blackhat144 sends brownie points to @bhushan933 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for bhushan933
blackhat144 sends brownie points to @bhushan933 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for bhushan933
blackhat144 sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star2: 1226 | @dhcodes |http://www.freecodecamp.com/dhcodes
shenoyabhijith sends brownie points to @blackhat144 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for blackhat144
Hey, I was making a random CSS transition thingy earlier some hours ago, (not a fcc challenge) and I just noticed that something's wrong with the output.
Here's my pen:
http://codepen.io/a-y-u-s-h/pen/VjQNpG?editors=0100
The problem is, I applied the same CSS for all li
elements, but the first card flips a bit differently than the others. Anyone knows how to fix that?
@siyafazila Nice one but why you didn’t make hero image’s width 100%? that would be better I think..
PS. I also finished my first project here and please see and let me know what are you thinking :) http://codepen.io/hiRevaz/pen/xOYBXE
https://code.jquery.com/jquery-2.2.4.min.js
and see?
var twitchArr = ["monstercat","freecodecamp", "noobs2ninjas"];
twitchArr.forEach(function(twitch) {
$.getJSON('https://api.twitch.tv/kraken/streams/' + twitch, function(data) {
if(data.stream===null){
}
});
});
max77p sends brownie points to @iserbit :sparkles: :thumbsup: :sparkles:
:cookie: 289 | @iserbit |http://www.freecodecamp.com/iserbit
https://
and the images with http://
- mixing transport types causes some issues. If you have a link to a project where you are trying to do this, perhaps we can confirm what the problem is?
https://
transport, but if you are using the free version of openweather, then http://
is required for that, so they won't cooperate together. The workaround is to use the IP-based site http://ip-api.com/json
which only works on http://
. Firefox supports (at least as of my last check) geolocation on http://
so it will work there, but you don't know what browser people will be using. I don't know if that gives you an answer for your question or if you have another? So you can potentially try the geolocation, and if it returns an error, then fall back to the ip-api site. Or just use http://ip-api.com/json
, potentially less accurate, but I don't really think that you need accuracy so much as to learn the techniques and design the site to work reliably.
$("#state2").click(function() {
$.getJSON("https://fcctop100.herokuapp.com/api/fccusers/top/alltime", function(data) {
$("#username1").html(data[0].username);
$("#recent1").html(data[0].recent);
$("#total1").html(data[0].alltime);
$("#username2").html(data[1].username);
$("#recent2").html(data[1].recent);
$("#total2").html(data[1].alltime);
$("#username3").html(data[2].username);
$("#recent3").html(data[2].recent);
$("#total3").html(data[2].alltime);
$("#username4").html(data[3].username);
$("#recent4").html(data[3].recent);
$("#total4").html(data[3].alltime);
$("#username5").html(data[4].username);
$("#recent5").html(data[4].recent);
$("#total5").html(data[4].alltime);
});
#username
, #recent
, and #total
- you might also have fixed divs or something in your HTML - you can generate the appropriate number of divs and append them to the DOM in a similar way, using jQuery.
var arr = [username1, username2, etc]
for (var i=0; i<arr.length; i++) {$("#arr[i]).html(data[i].username}
lhovee sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1452 | @khaduch |http://www.freecodecamp.com/khaduch
lhovee sends brownie points to @radascript :sparkles: :thumbsup: :sparkles:
:cookie: 367 | @radascript |http://www.freecodecamp.com/radascript
getJSON
and click
can't deviate from what the program expects .... ideas?var arr = [username1, recent1, total1, username2, recent2, total2, username3, recent3, total3, username4, recent4, total4, username5, recent5, total5];
$(document).ready(function() {
$("#state2").click(function() {
$.getJSON("https://fcctop100.herokuapp.com/api/fccusers/top/alltime", function(data) {
for (var i = 0; i < arr.length; i++) {
if (i == 0 || i == 3 || i == 6 || i == 9 || i == 12) {
$("#arr[i]").html(data[i].username)
};
else if (i == 1 || i == 4 || i == 7 || i == 10 || i == 13) {
$("#arr[i]").html(data[i].recent)
};
else if (i == 2 || i == 5 || i == 8 || i == 11 || i == 14) {
$("#arr[i]").html(data[i].total)
};
};
});
});
lhovee sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1260 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
$("#state1").click(function() {
$.getJSON("https://fcctop100.herokuapp.com/api/fccusers/top/recent", function(data) {
$("#username1").html(data[0].username);
$("#recent1").html(data[0].recent);
$("#total1").html(data[0].alltime);
$("#username2").html(data[1].username);
$("#recent2").html(data[1].recent);
$("#total2").html(data[1].alltime);
$("#username3").html(data[2].username);
$("#recent3").html(data[2].recent);
$("#total3").html(data[2].alltime);
$("#username4").html(data[3].username);
$("#recent4").html(data[3].recent);
$("#total4").html(data[3].alltime);
$("#username5").html(data[4].username);
$("#recent5").html(data[4].recent);
$("#total5").html(data[4].alltime);
});
});
var iconColumn = $('<div>');
$(iconColumn).appendTo(channelItem);
$(buttonObj.buttonID).css('background', buttonObj.buttonBG);
$.getJSON("https://fcctop100.herokuapp.com/api/fccusers/top/alltime", function(data) {
var arr = ["#username1", "#recent1", "#total1", "#username2", "#recent2", "#total2", "#username3", "#recent3", "#total3", "#username4", "#recent4", "#total4", "#username5", "#recent5", "total5"];
for (var i = 0; i < arr.length; i++) {
if (i == 0 || i == 3 || i == 6 || i == 9 || i == 12) {
$(arr[i]).html(data[i].username);
} else if (i == 1 || i == 4 || i == 7 || i == 10 || i == 13) {
$(arr[i]).html(data[i].recent);
} else if (i == 2 || i == 5 || i == 8 || i == 11 || i == 14) {
$(arr[i]).html(data[i].total);
}
};
});
});