- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
用于推文当前报价的 jQuery 单击功能不起作用。我必须构建随机报价机并在 Twitter 上发布 Free Code Camp 的当前报价。我可以生成新报价,但无法在 Twitter 上分享该报价。有人会告诉我我做错了什么吗?
我的代码位于此处:FCC Random Quote Machine
$(document).ready(function() {
generate();
function generate(){
var quotes = [
'If you want to achieve greatness stop asking and for permission. @Anonymous',
'Things work out best for those who make the best of how things work out. @John Wooden',
'To live a creative life, we must lose our fear of being wrong. @Anonymous',
'If you are not willing to risk the usual you will have to settle for the ordinary. @Jim Rohn',
'Trust because you are willing to accept the risk, not because it\'s safe or certain. @Anonymous',
'Take up one idea. Make that one idea your life - think of it, dream of it, live on that idea. Let the brain, muscles, nerves, every part of your body, be full of that idea, and just leave every other idea alone. This is the way to success. @Swami Vivekananda',
'All our dreams can come true if we have the courage to pursue them. @Walt Disney',
'Good things come to people who wait, but better things come to those who go out and get them. @Anonymous',
'If you do what you always did, you will get what you always got. @Anonymous',
'Success is walking from failure to failure with no loss of enthusiasm. @Winston Churchill',
'Just when the caterpillar thought the world was ending, he turned into a butterfly. @Proverb',
'Successful entrepreneurs are givers and not takers of positive energy. @Anonymous',
'Whenever you see a successful person you only see the public glories, never the private sacrifices to reach them. @Vaibhav Shah',
'Opportunities don\'t happen, you create them. @Chris Grosser',
'Try not to become a person of success, but rather try to become a person of value. @Albert Einstein',
'Great minds discuss ideas; average minds discuss events; small minds discuss people. @Eleanor Roosevelt',
'I have not failed. I\'ve just found 10,000 ways that won\'t work. @Thomas A. Edison',
'If you don\'t value your time, neither will others. Stop giving away your time and talents - start charging for it. @Kim Garst',
'A successful man is one who can lay a firm foundation with the bricks others have thrown at him. @David Brinkley',
'No one can make you feel inferior without your consent. @Eleanor Roosevelt',
'The whole secret of a successful life is to find out what is one\'s destiny to do, and then do it. @Henry Ford',
'If you\'re going through hell keep going. @Winston Churchill',
'The ones who are crazy enough to think they can change the world, are the ones who do. @Anonymous',
'Don\'t raise your voice, improve your argument. @Anonymous',
'What seems to us as bitter trials are often blessings in disguise. @Oscar Wilde',
'The meaning of life is to find your gift. The purpose of life is to give it away. @Anonymous',
'The distance between insanity and genius is measured only by success. @Bruce Feirstein',
'When you stop chasing the wrong things, you give the right things a chance to catch you. @Lolly Daskal',
'I believe that the only courage anybody ever needs is the courage to follow your own dreams. @Oprah Winfrey',
'No masterpiece was ever created by a lazy artist. @Anonymous',
'Happiness is a butterfly, which when pursued, is always beyond your grasp, but which, if you will sit down quietly, may alight upon you. @Nathaniel Hawthorne',
'If you can\'t explain it simply, you don\'t understand it well enough. @Albert Einstein',
'Blessed are those who can give without remembering and take without forgetting. @Anonymous',
'Do one thing every day that scares you. @Anonymous',
'What\'s the point of being alive if you don\'t at least try to do something remarkable. @Anonymous',
'Life is not about finding yourself. Life is about creating yourself. @Lolly Daskal',
'Nothing in the world is more common than unsuccessful people with talent. @Anonymous',
'Knowledge is being aware of what you can do. Wisdom is knowing when not to do it. @Anonymous',
'Your problem isn\'t the problem. Your reaction is the problem. @Anonymous',
'You can do anything, but not everything. @Anonymous',
'Innovation distinguishes between a leader and a follower. @Steve Jobs',
'There are two types of people who will tell you that you cannot make a difference in this world: those who are afraid to try and those who are afraid you will succeed. @Ray Goforth',
'Thinking should become your capital asset, no matter whatever ups and downs you come across in your life. @A.P.J. Abdul Kalam',
'I find that the harder I work, the more luck I seem to have. @Thomas Jefferson',
'The starting point of all achievement is desire. @Napoleon Hill',
'Success is the sum of small efforts, repeated day-in and day-out. @Robert Collier',
'If you want to achieve excellence, you can get there today. As of this second, quit doing less-than-excellent work. @Thomas J. Watson',
'All progress takes place outside the comfort zone. @Michael John Bobak',
'You may only succeed if you desire succeeding; you may only fail if you do not mind failing. @Philippos',
'Courage is resistance to fear, mastery of fear - not absence of fear. @Mark Twain',
'Only put off until tomorrow what you are willing to die having left undone. @Pablo Picasso',
'People often say that motivation doesn\'t last. Well, neither does bathing - that\'s why we recommend it daily. @Zig Ziglar',
'We become what we think about most of the time, and that\'s the strangest secret. @Earl Nightingale',
'The only place where success comes before work is in the dictionary. @Vidal Sassoon',
'Too many of us are not living our dreams because we are living our fears. @Les Brown',
'I find that when you have a real interest in life and a curious life, that sleep is not the most important thing. @Martha Stewart',
'It\'s not what you look at that matters, it\'s what you see. @Anonymous',
'The road to success and the road to failure are almost exactly the same. @Colin R. Davis',
'The function of leadership is to produce more leaders, not more followers. @Ralph Nader',
'Success is liking yourself, liking what you do, and liking how you do it. @Maya Angelou',
'As we look ahead into the next century, leaders will be those who empower others. @Bill Gates',
'A real entrepreneur is somebody who has no safety net underneath them. @Henry Kravis',
'The first step toward success is taken when you refuse to be a captive of the environment in which you first find yourself. @Mark Caine',
'People who succeed have momentum. The more they succeed, the more they want to succeed, and the more they find a way to succeed. Similarly, when someone is failing, the tendency is to get on a downward spiral that can even become a self-fulfilling prophecy. @Tony Robbins',
'When I dare to be powerful, to use my strength in the service of my vision, then it becomes less and less important whether I am afraid. @Audre Lorde',
'Whenever you find yourself on the side of the majority, it is time to pause and reflect. @Mark Twain',
'The successful warrior is the average man, with laser-like focus. @Bruce Lee',
'There is no traffic jam along the extra mile. @Roger Staubach',
'Develop success from failures. Discouragement and failure are two of the surest stepping stones to success. @Dale Carnegie',
'If you don\'t design your own life plan, chances are you\'ll fall into someone else\'s plan. And guess what they have planned for you? Not much. @Jim Rohn',
'If you genuinely want something, don\'t wait for it - teach yourself to be impatient. @Gurbaksh Chahal',
'Don\'t let the fear of losing be greater than the excitement of winning. @Robert Kiyosaki',
'If you want to make a permanent change, stop focusing on the size of your problems and start focusing on the size of you! @T. Harv Eker',
'You can\'t connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future. You have to trust in something - your gut, destiny, life, karma, whatever. This approach has never let me down, and it has made all the difference in my life. @Steve Jobs',
'Two roads diverged in a wood and I took the one less traveled by, and that made all the difference. @Robert Frost',
'The number one reason people fail in life is because they listen to their friends, family, and neighbors. @Napoleon Hill',
'The reason most people never reach their goals is that they don\'t define them, or ever seriously consider them as believable or achievable. Winners can tell you where they are going, what they plan to do along the way, and who will be sharing the adventure with them. @Denis Waitley',
'In my experience, there is only one motivation, and that is desire. No reasons or principle contain it or stand against it. @Jane Smiley',
'Success does not consist in never making mistakes but in never making the same one a second time. @George Bernard Shaw',
'I don\'t want to get to the end of my life and find that I lived just the length of it. I want to have lived the width of it as well. @Diane Ackerman',
'You must expect great things of yourself before you can do them. @Michael Jordan',
'Motivation is what gets you started. Habit is what keeps you going. @Jim Ryun',
'People rarely succeed unless they have fun in what they are doing. @Dale Carnegie',
'There is no chance, no destiny, no fate, that can hinder or control the firm resolve of a determined soul. @Ella Wheeler Wilcox',
'Our greatest fear should not be of failure but of succeeding at things in life that don\'t really matter. @Francis Chan',
'You\'ve got to get up every morning with determination if you\'re going to go to bed with satisfaction. @George Lorimer',
'A goal is not always meant to be reached; it often serves simply as something to aim at. @Bruce Lee',
'Success is ... knowing your purpose in life, growing to reach your maximum potential, and sowing seeds that benefit others. @John C. Maxwell',
'Be miserable. Or motivate yourself. Whatever has to be done, it\'s always your choice. @Wayne Dyer',
'To accomplish great things, we must not only act, but also dream, not only plan, but also believe. @Anatole France',
'Most of the important things in the world have been accomplished by people who have kept on trying when there seemed to be no help at all. @Dale Carnegie',
'You measure the size of the accomplishment by the obstacles you had to overcome to reach your goals. @Booker T. Washington',
'Real difficulties can be overcome; it is only the imaginary ones that are unconquerable. @Theodore N. Vail',
'It is better to fail in originality than to succeed in imitation. @Herman Melville',
'What would you do if you weren\'t afraid. @Spencer Johnson',
'Little minds are tamed and subdued by misfortune; but great minds rise above it. @Washington Irving',
'Failure is the condiment that gives success its flavor. @Truman Capote',
'Don\'t let what you cannot do interfere with what you can do. @John R. Wooden',
'You may have to fight a battle more than once to win it. @Margaret Thatcher',
'A man can be as great as he wants to be. If you believe in yourself and have the courage, the determination, the dedication, the competitive drive and if you are willing to sacrifice the little things in life and pay the price for the things that are worthwhile, it can be done. @Vince Lombardi'
];
randomQuote = quotes[Math.floor(Math.random()*quotes.length)];
quoteAuthor=randomQuote.split("@");
$('.quote').text(quoteAuthor[0]);
$('.author').text(quoteAuthor[1]);
}
function shareQuote(quote, author) {
var webpage = "http://codepen.io/lindakovacs/pen/EWjyyZ";
var twitterAction = "https://twitter.com/intent/tweet?text=";
$('#tweetBtn').attr("href", twitterAction + quote + " -" + author + " " + webpage);
}
$("#new-quote").on("click", function() {
generate();
});
});
@import url('https://fonts.googleapis.com/css?family=Great+Vibes');
@import url('https://fonts.googleapis.com/css?family=Alex+Brush');
* {
margin: 0px;
padding: 2px;
}
.container{
text-align:center;
}
h1{
font-size: 40px;
font-family: 'Great Vibes', cursive;
color: #4d2700;
display:block;
text-align: center;
width: 80%;
margin: 0px auto;
padding: 10px 0;
}
header a, a:visited {
text-decoration:none;
color:#fcfcfc;
}
.a {
text-decoration:none;
}
.btn-blue {
background-color: #3861EC;
color: #fff;
border: none;
text-decoration:none;
}
body {
background: url('http://www.nyantler-outdoors.com/images/aged-parchment.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.quotes {
font-family: 'Alex Brush', cursive;
font-size: 40px;
font-weight: bold;
margin: 50px auto;
position: relative;
width: 40%;
}
.author {
font-family: 'Alex Brush', cursive;
font-size: 30px;
font-weight: bold;
margin: 50px auto;
width: 40%;
position: relative;
}
.divider {
height: 0.5px;
width: 10%;
margin: 0 auto;
margin-top: 10px;
opacity: 0.5;
position: relative;
background-color: #000000;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Random Quote Machine - Free Code Camp</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Boostrap -->
<link rel='stylesheet prefetch' href='//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'>
<link rel='stylesheet prefetch' href='//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css'>
<link rel='stylesheet prefetch' href='//cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css'>
<!-- Link styles -->
<link rel="stylesheet" href="css/style.css" />
<link href='//fonts.googleapis.com/css?family=Arizonia' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Alex+Brush' rel='stylesheet' type='text/css'>
<!-- Link scripts -->
<script src="js/script.js"></script>
</head>
<body>
<div class="container text-center">
<h1>Your Daily Dose of Inspiration</h1>
<div class="btn btn-blue text-centre" id="tweetBtn" target="_blank">
<a class="twitter-share-button" href="https://twitter.com/intent/tweet?text=" data-size="large"><span class="fa fa-twitter"></span> Tweet</a>
</div>
<div class="btn btn-blue text-centre" id="new-quote" target="_blank"><span class="fa fa-chevron-right"></span> Get inspired
</div>
</div>
<div class="quotes text-center">
<span class="quote"></span><br>
<div class="divider"></div>
<span class="author"></span>
</div>
<footer class="navbar-fixed-bottom text-center">
<div class="fixfooter">
<p id="footer">By Linda Kovacs 2017</p>
</div>
</footer>
</body>
</html>
最佳答案
我弄清楚了如何让我的代码在 Twitter 上分享报价。我还在引号中将 @ 更改为 - :
randomQuote = quotes[Math.floor(Math.random()*quotes.length)];
quoteAuthor=randomQuote.split("-");
quote = $('.quote').text(quoteAuthor[0]);
author = $('.author').text(quoteAuthor[1]);
}
$('#tweetBtn').on('click', function(){
window.open('https://twitter.com/intent/tweet?text='+ randomQuote + ' | A CoDePen by LindaKovacs 2017', 'Share', 'width=700, height=500, toolbar=0, scrollbars=1, location=0, statusbar=0, menubar=0, resizable=1');
});
$("#new-quote").on("click", function() {
generate();
});
});
关于javascript - 无法分享包含引用和作者的推文(FCC 随机引用机),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42570260/
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: template pass by value or const reference or…? 以下对于将函数
我用相同的参数列表重载了一个运算符两次。但返回类型不同: T& operator()(par_list){blablabla} const T& operator()(par_list){bla
假设我有实现接口(interface) I 的 Activity A。我的 ViewModel 类 (VM) 持有对实现接口(interface) I 的对象的引用: class A extends
PHP 如何解释 &$this ?为什么允许? 我遇到了以下问题,这看起来像是 PHP 7.1 和 7.2 中的错误。它与 &$this 引用和跨命名空间调用以及 call_user_func_arr
谁能解释一下下面“&”的作用: class TEST { } $abc =& new TEST(); 我知道这是引用。但是有人可以说明我为什么以及什么时候需要这样的东西吗?或者给我指向一个对此有很好解
引用变量是一个别名,也就是说,它是某个已存在变量的另一个名字。一旦把引用初始化为某个变量,就可以使用该引用名称或变量名称来指向变量。 C++ 引用 vs 指针 引用很容易与指针混淆,它们之间有三
目录 引言 背景 结论 引言 我选择写C++中的引用是因为我感觉大多数人误解了引用。而我之所以有这个感受是因为我主持过很多C++的面试,并且我很少
Perl 中的引用是指一个标量类型可以指向变量、数组、哈希表(也叫关联数组)甚至函数,可以应用在程序的任何地方 创建引用 定义变量的时候,在变量名前面加个 \,就得到了这个变量的一个引用 $sc
我编写了一个将从主脚本加载的 Perl 模块。该模块使用在主脚本中定义的子程序(我不是维护者)。 对于主脚本中的一个子例程,需要扩展,但我不想修补主脚本。相反,我想覆盖我的模块中的函数并保存对原始子例
我花了几个小时试图掌握 F# Quotations,但我遇到了一些障碍。我的要求是从可区分的联合类型中取出简单的函数(只是整数、+、-、/、*)并生成一个表达式树,最终将用于生成 C 代码。我知道使用
很多时候,问题(尤其是那些标记为 regex 的问题)询问验证密码的方法。似乎用户通常会寻求密码验证方法,包括确保密码包含特定字符、匹配特定模式和/或遵守最少字符数。这篇文章旨在帮助用户找到合适的密码
我想通过 MIN 函数内的地址(例如,C800)引用包含文本的最后一个单元格。你能帮忙吗? Sub Set_Formula() ' ----------------------------- Dim
使用常规的 for 循环,我可以做类似的事情: for (let i = 0; i < objects.length; i++) { delete objects[i]; } 常规的 for-
在 Cucumber 中,您定义了定义 BDD 语法的步骤;例如,您的测试可能有: When I navigate to step 3 然后你可以定义一个步骤: When /^I navigate t
这是什么UnaryExpression的目的,以及应该怎样使用? 最佳答案 它需要一个 Expression对象并用另一个 Expression 包裹它.例如,如果您有一个用于 lambda 的表达式
给出以下内容 $("#identifier div:first, #idetifier2").fadeOut(300,function() { // I need to reference jus
我不知道我要找的东西的正确术语,但我要找的是一个完整的引用,可以放在双引号之间的语句,比如 *, node()、@* 以及所有列出的 here加上任何其他存在的。 我链接到的答案提供了一些细节,但还
This question's answers are a community effort。编辑现有答案以改善此职位。它当前不接受新的答案或互动。 这是什么? 这是常见问答的集合。这也是一个社区Wi
Closed. This question does not meet Stack Overflow guidelines。它当前不接受答案。 想改善这个问题吗?更新问题,以便将其作为on-topic
考虑下一个代码: fn get_ref(slice: &'a Vec, f: fn(&'a Vec) -> R) -> R where R: 'a, { f(slice) } fn m
我是一名优秀的程序员,十分优秀!