.html() , innerHTML() und .text() ändern den Text nichtJquery

JQuery-Programmierung
Anonymous
 .html() , innerHTML() und .text() ändern den Text nicht

Post by Anonymous »

Ich habe alle drei ausprobiert, aber es scheint den Text nicht zu ändern. Ich habe eine Reihe zufälliger Anführungszeichen, die ich auf dem Bildschirm anzeigen möchte, und versuche, sie zu ändern, aber die von mir verwendeten JQuery-Methoden scheinen nicht zu funktionieren. Hier ist mein HTML- und Javascript-Code.
Hier ist ein Ausschnitt meines aktuellen Codes und was ich bisher tatsächlich versucht habe:

Code: Select all

    var main = function() {

var colors = ["#ED2007", "#EDAB07", "#ECF30A", "#69F30A", "#0AF3E8", "#0A69F3", "#DE0AF3", "#F30ADE"];

var quotes = [
"If you have nothing, are you a nillionaire?",
"Turning up the volume is like zooming in, but with sound.",
"If I eat myself, will I get twice as big, or disappear completely?",
"Out of my mind. Back in five minutes",
"I’m not a complete idiot — Some parts are missing."
];

//begin
//when btn-1 is click, perform following
$(".btn-1").click(function(){
var $this = $(this);
$this.button('loading');
setTimeout(function() {
//begin loop

for(var i = 0; i < quotes.length; i++){
var randQuote =
((Math.random() * quotes[i].length-1) + 0);

switch(randQuote){
case 0:

$('#quote').html("If you have nothing, are you a nillionaire?");

break;

case 1:

$('#quote').html("Turning up the volume is like zooming in, but with sound.");

break;

case 2:

$('#quote').html("If I eat myself, will I get twice as big, or disappear completely?");

break;

case 3:

$('#quote').html("Out of my mind.  Back in five minutes");

break;

case 4:

$('#quote').html("I’m not a complete idiot — Some parts are missing.");

break;

default:

$('#quote').html("Press New Quote Button for a random quote");

}
}
//end loop

for(var j = 0; j < colors.length; j++){
var randColor = Math.floor((Math.random() * colors[j].length-1) + 0);

switch(randColor){
case 0:                                       document.body.style.backgroundColor = "#ED2007";
$this.css('background-color', '#ED2007');
break;

case 1:
document.body.style.backgroundColor = "#EDAB07";

$this.css('background-color', '#EDAB07');
break;

case 2:
document.body.style.backgroundColor ="#ECF30A";
$this.css('background-color', '#ECF30A');
break;

case 3:
document.body.style.backgroundColor = "#69F30A";
$this.css('background-color', '#69F30A');

break;

case 4:
document.body.style.backgroundColor ="#0AF3E8";
$this.css('background-color', '#0AF3E8');
break;

case 5:
document.body.style.backgroundColor = "#0A69F3";
$this.css('background-color', '#0A69F3');
break;

case 6:
document.body.style.backgroundColor = "#DE0AF3";
$this.css('background-color', '#DE0AF3');
break;

case 7:
document.body.style.backgroundColor="#F30ADE";
$this.css('background-color', '#F30ADE');
break;

default:
document.body.style.backgroundColor="#00ccff";
$this.css('background-color', '#00ccff');

}
}
$this.button('reset');

}, 4000);
});
//end

//when tumblr btn is click, perform following
$(".fa-tumblr-square").click(function(){
location.href = "https://www.tumblr.com/";
});

//when twitter btn is click, perform following
$(".fa-twitter-square").click(function(){
location.href = 'https://twitter.com/intent/tweet?text=';
});

};

$(document).ready(main);

Code: Select all







Random Quote Machine






"Press New Quote Button for a random quote"


[i][/i]
[i][/i]

New Quote



[url=https://codepen.io/natekicksa/]By:Nate[/url]


Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post
  • .html() , innerHTML() und .text() ändern den Text nicht
    by Anonymous » » in HTML
    0 Replies
    4 Views
    Last post by Anonymous
  • Textdatei lesen und Ergebnis in innerHTML einfügen?
    by Guest » » in HTML
    0 Replies
    33 Views
    Last post by Guest
  • Textdatei lesen und Ergebnis in innerHTML einfügen?
    by Guest » » in JavaScript
    0 Replies
    32 Views
    Last post by Guest
  • Schriftart großartige Symbole innerhtml
    by Anonymous » » in HTML
    0 Replies
    32 Views
    Last post by Anonymous
  • Wie ersetzt ich die Innerhtml eines DIV mit JQuery?
    by Anonymous » » in Jquery
    0 Replies
    13 Views
    Last post by Anonymous