Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 你清楚我想做什么:Thanks@Lona-凯瑟琳·埃文斯,我明白你想做什么,但你希望我如何帮助你?如果您希望有人修改您的代码,那么我已经用更新的HTML&JS更新了我的答案,并对其进行了注释,使其更易于理解。 $(document).ready (fu_Javascript_Jquery - Fatal编程技术网

Javascript 你清楚我想做什么:Thanks@Lona-凯瑟琳·埃文斯,我明白你想做什么,但你希望我如何帮助你?如果您希望有人修改您的代码,那么我已经用更新的HTML&JS更新了我的答案,并对其进行了注释,使其更易于理解。 $(document).ready (fu

Javascript 你清楚我想做什么:Thanks@Lona-凯瑟琳·埃文斯,我明白你想做什么,但你希望我如何帮助你?如果您希望有人修改您的代码,那么我已经用更新的HTML&JS更新了我的答案,并对其进行了注释,使其更易于理解。 $(document).ready (fu,javascript,jquery,Javascript,Jquery,你清楚我想做什么:Thanks@Lona-凯瑟琳·埃文斯,我明白你想做什么,但你希望我如何帮助你?如果您希望有人修改您的代码,那么我已经用更新的HTML&JS更新了我的答案,并对其进行了注释,使其更易于理解。 $(document).ready (function(){ function getRandomArbitrary(0,2){ var x = Math.random() * (2 - 0) + 0; } $(document).ready (function(){ f


你清楚我想做什么:Thanks@Lona-凯瑟琳·埃文斯,我明白你想做什么,但你希望我如何帮助你?如果您希望有人修改您的代码,那么我已经用更新的HTML&JS更新了我的答案,并对其进行了注释,使其更易于理解。
  $(document).ready (function(){
  function getRandomArbitrary(0,2){
  var x = Math.random() * (2 - 0) + 0;
  }
$(document).ready (function(){
function getRandomArbitrary(low,high){
var low = 0;
var high = 2;
var x = Math.random() * (high - low) + low;
return x;
}

function getQuote(){

var obj1 = [ {author: "-Jeremiah 29:11", quote: "For I know the plans I   have for you,” declares the LORD, “plans to prosper you and not to harm   you, plans to give you hope  and a future."},

{ quote: "If God called us to a task, He will then qualify us for the   job."},

{author:"-1Timothy 6:12", quote: "“Fight the good fight of the faith.   Take hold of the eternal life to which you were called and about which you   made the good confession in the presence of many witnesses."},
        ];

$(".quote").text(obj1[x].quote);
$(".author").text(obj1[x].author);
}


$(".button").on("click", function(){
  getQuote();
});
});
function getRandomArbitrary(low, high){
    var x = Math.random() * (high - low) + low;
}
function getRandomArbitrary() {
  // determine "low" and "high" values (once)
  var low = 0,
    high = 2;
  // calculate the result
  var x = Math.random() * (high - low) + 0;
  // return the result.
  return x;
}
function getRandomArbitrary(low, high) {
  // calculate the result
  var x = Math.random() * (high - low) + 0;
  // return the result.
  return x;
}
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta content="IE=edge" http-equiv="X-UA-Compatible" />
  <meta content="width=device-width, initial-scale=1" name="viewport" />
  <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
  <title>Quote Generator =)</title>
  <!-- Bootstrap -->
  <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
  <link rel="stylesheet" type="text/css" href="style.css" />
  <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Amatic+SC" />
  <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>
<body>
  <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <div class="container">
    <header class="header"><b>Random Quote Generator</b></header>
    <div class="box">
      <input type="button" value="click me for quote" class="button" />
      <div class="quotes">
        <span class="quote"><h1></h1></span>
        <span class="author"><h1></h1></span>
        <div id="share-buttons">
          <a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://codepen.io/ionakathryn/pen/YWEPkz";text=Random Quote Generator: www.ionakathryn.com&amp; target="_blank">
            <img src="https://simplesharebuttons.com/images/somacro/linkedin.png" alt="LinkedIn" />
          </a>
          <a href="https://twitter.com/share?url=https://twitter.com&amp;text=Random Quote Generator: www.ionakathryn.com&amp;hashtags=FreeCodeCamp" target="_blank">
            <img src="https://simplesharebuttons.com/images/somacro/twitter.png" alt="Twitter" />
          </a>
          <a href="http://www.facebook.com/sharer.php?u=https://codepen.io/ionakathryn/pen/YWEPkz";text= ".quotes"&amp; target=".quotes">
            <img src="https://simplesharebuttons.com/images/somacro/facebook.png" alt="Facebook" />
          </a>
        </div>
      </div>
    </div>
  </div>
  <!-- Include all compiled plugins (below), or include individual files as needed -->
  <script type="text/javascript" src="js/bootstrap.min.js"></script>
</body>
</html>
// I've noticed that you might use multiple plugins and / or libraries
// so I've written "jQuery(document).ready(function($) {" so that the "$" variable is definitely assigned to jQuery inside the "document ready"
jQuery(document).ready(function($) {
  // removed the quotes list from the function
  // you can even place it above the "document ready" function
  // or even make the quotes variable a global using "window.quotes =" instead of "var quotes ="
  var quotes = [{
    // changed the "quote" to "text" to make it look a little less confusing inside the click function
    "author": "- Jeremiah 29:11",
    "text": "'For I know the plans I have for you,” declares the LORD, “plans to prosper you and not to harm you, plans to give you hope  and a future.'"
  }, {
    "author": "- anonymous",
    "text": "'If God called us to a task, He will then qualify us for the job.'"
  }, {
    "author": "- 1Timothy 6:12",
    "text": "'Fight the good fight of the faith. Take hold of the eternal life to which you were called and about which you made the good confession in the presence of many witnesses.'"
  }, {
    "author": "- Luke 6:31",
    "text": "'Do to others as you would have them do to you.'"
  }, {
    "author": "- 1 Corinthians 13:13",
    "text": "'And now these three remain: faith, hope and love. But the greatest of these is love.'"
  }, {
    "author": "- 1 John 4:8",
    "text": "'Whoever does not love does not know God, because God is love.'"
  }, {
    "author": "- Romans 15:13",
    "text": "'Now may the God of hope fill you with all joy and peace in believing, that you may abound in hope by the power of the Holy Spirit.'"
  }, {
    "author": "- Ecclesiastes 9:10",
    "text": "'Whatever your hand finds to do, do it with all your might.'"
  }, {
    "author": "- Proverbs 12:25",
    "text": "'Anxiety in a man’s heart weighs it down, but an encouraging word makes it glad.'",
  }, {
    "author": "- Mark 9:23",
    "text": "'If you can believe, all things are possible to him who believes.'",
  }];

  // removed the external "getQuote" function as it wasn't unnecessary
  // I'm assuming this because you only use it once
  $(".button").on("click", function() {
    // simplified the process of updating the quote
    var q = quotes[Math.floor(Math.random() * quotes.length)];
    $(".quote").text(q.text).next().text(q.author);
  });
});