n1ckl3 sends brownie points to @steveamaki :sparkles: :thumbsup: :sparkles:
:cookie: 127 | @steveamaki |http://www.freecodecamp.com/steveamaki
n1ckl3 sends brownie points to @jamesscruggs :sparkles: :thumbsup: :sparkles:
:cookie: 268 | @jamesscruggs |http://www.freecodecamp.com/jamesscruggs
Bled my eyeballs out tinkering on this code and I'm happy how its turning out! Check it out yall!
cameron-burkholder sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 3389 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
I have a div tag. When I try to get the value with jQuery, the console.log just returns nothing.
var getVal = $('#tempVal').val();
console.log(getVal);
If I do the following, I just get NaN:
var getVal = $('#tempVal').val().toNumber();
console.log(getVal);
+"123"
123
$.ajaxSetup
changes all ajax calls on the page though, so it's discouraged, but it should work for the purposes of that project
@tbc13315 well they also support it as url param so just append it
apiURL + '&client_id=yourkey'
or
$.getJSON(apiURL, {client_id:'yourkey'}).done(...).fail(...);
on $.ajax
$.ajax({
url: apiURL,
data: {client_id:'yourkey'},
...
})
.done(...)
.fail(...);
function addText(obj) {
var e = document.getElementById('twitter-button');
if(e.firstChild !== null) e.removeChild(e.firstChild);
var author = obj.author.toString();
var quote = obj.quote.toString();
document.getElementById("random_quote").innerHTML = quote;
document.getElementById("random_author").innerHTML = author;
}
:bulb: to format code use backticks! ``` more info
<input class="check" type="checkbox">
$(".check").click(function() {
if ($(this).checked){
$("img").hide();
}else {
$("img").show();
}
});
this.checked
:cookie: 449 | @u-ways |http://www.freecodecamp.com/u-ways
kevinangga sends brownie points to @u-ways :sparkles: :thumbsup: :sparkles:
Hi, I am currently working on the random quote machine. Can somebody tell me how to make the twitter button share the quote and author (not the link to my pen)?
iframe
you can verify that in chrome dev tools. So use your own a
tag style it as button and change its href in JS dynamically using http://twitter.com/share?text=your quote and author
aleks1406 sends brownie points to @vinaypuppal :sparkles: :thumbsup: :sparkles:
:cookie: 554 | @vinaypuppal |http://www.freecodecamp.com/vinaypuppal
footer {
height: 100px;
display: flex;
justify-content: center;
align-items: center;
}
p
horizontally and vertically
function newChoice(){
ind= [Math.floor(Math.random() * choices.length)];
seq=choices[ind];
return seq;
}
function cpuSeq() {
count++;
newChoice(); //seq is the value of random choice element
interval =
setInterval(function() {
if(cSeq.length>=1){ for(i=0;i<cSeq.length;i++){
//IF cpuSeq has notes in it... play them again before making new ones.
audioF[cSeq[i].toLowerCase].play(); } }
audioF[seq.toLowerCase()].play();
cSeq.push(seq);
console.log(cSeq + cSeq.length, pSeq);
newChoice();
if(cSeq.length>=count){clearInterval(interval);
cSeq=[];}
}, 1000);
}
Can someone advise me how to make CpuChoice remember past choices in Cseq Array and so make the cPu choose past choices before using random choices???
not sure if this is where i should ask this, but here it goes.
when i'm doing my portfolio page, i'm adding the collapse on my navbar for mobile, but my navbar is not opening.
here is my codepen: http://codepen.io/maniacalkitten/full/ORRVJB/
and i added the following in my CodePen settings:
jQuery
jQuery UI
Bootstrap
function planetInfo(name, distance, diameter) {
this.name = name;
this.distance = function(x) {
var number = 40;
return x * 40;
};
this.margin = function(margin) {
return ((distance - 5) / 2);
};
}
var venus = new planetInfo("venus", 0.72, 0.949);
console.log(venus);
When I try to log venus, I get the name just fine, but the distance and margin values simply show up as 'function'
function planetInfo(name, distance, diameter) {
this.name = name;
this.distance = diameter*40;
this.margin =((this.distance - 5) / 2);
}
var venus = new planetInfo("venus", 0.72, 0.949);
console.log(venus);
distance
and margin
as a function if you wanna a property
href="#contact"
which means direct to the element which id="contact"
so that's the reason
position: relative
to your .description
class in your style sheet.
position:absolute
are based on the parent element of the descriptions --- the body
root.
@mhdavis no wrap your code in between tic marks...`
code here`
<section class="jumbotron">
<div class="container">
<h2>insert thing here</h2>
</div>
</section>
placeholder="Type anything you want to look up."
this for your input rather than value=
html += "<div class='well'>";
change from = to += as is here to get all articles
data.stream === null
it is stream that is null for offline
So I ended up making variables to define random a random quote and it's auther. Once I had those variables I added to the tweet text link like this.
("https://twitter.com/intent/tweet/?text="+ randomQuote + " " + randomAuthor);
Here's the pen if you'd like to take a look. Don't forget to like it.
http://codepen.io/tourdejord-1470883108/pen/yaNzJj?editors=0010
Can someone help me with my Javascript?
Here is my site: http://utilitan.com/randomcolor/javascriptPractice.html
I think you will see what the problem is, but:
1) The boxes are shifted over like 2px from the first (initial) box,
2) the rest of the boxes don't change color
$.getJSON("api.openweathermap.org/data/2.5/weather?q=London&APPID=(myid)", function(json) {
$("#location").html(JSON.stringify(json));
});
I'm trying to post all of the json for the city of london to an h3 tag with id="location" using jquery just to see if the API is working.. It's not working though. Any suggestions?
$('.tweet-button iframe').remove();
// Generate new markup
var tweetBtn = $('<a></a>')
.addClass('twitter-hashtag-button')
.attr('href', 'https://twitter.com/intent/tweet?button_hashtag=freecodecamp')
.attr('data-size', "large")
.attr('data-text', quote.quote);
$('.tweet-button').append(tweetBtn);
twttr.widgets.load();
$('#watchaLookingFor').keydown(function(e) {
if (e.which == 13) { //enter key detected
$('.results').empty(); //empty out the results from previous
var input = $('#watchaLookingFor').val(); //get the value from the input
$.getJSON('https://en.wikipedia.org/w/api.php?callback=?&action=query&list=search&srsearch=' + input + '&srwhat=text&srprop=snippet&continue=&utf8&prop=links&format=json', function(data) {
for (var i = 0; i < data.query.search.length; i++) {
$('.results').append('<article>' + '<h2><b>' + data.query.search[i].title + '</b></h2>' + '<p>' + data.query.search[i].snippet + '.</p>' + '</article>');
}
})
}
});
$('#submit').submit(function() {
$('.results').empty();
return $.getJSON('https://en.wikipedia.org/w/api.php?callback=?&action=query&list=search&srsearch=' + document.getElementsByName('input')[0].value + '&srwhat=text&srprop=snippet&continue=&utf8&prop=links&format=json', function(data) {
for (var i = 0; i < data.query.search.length; i++) {
$('.results').append('<article>' + '<h2><b>' + data.query.search[i].title + '</b></h2>' + '<p>' + data.query.search[i].snippet + '.</p>' + '</article>');
}
})
});
$('#watchaLookingFor').val(''); //clear the text in input