ランダムクォートジェネレーターの作成に取り組んでいます。私はそれがほとんどquotesondesign.comのAPIを使用して終了しているが、私がする必要がある最後のことは、新しい見積もりボタンをクリックすると、新しい引用にTwitterのボタンを更新することです。しかし、それは変わることはありませんし、私はなぜそれがわからないのですか?私はちょうどスタイルと、そのようなを変更する実行する前に作業機能を取得しようと、それは醜いと適切に設定されていないのです実現https://codepen.io/Uberche/pen/RLbjbpJavaScriptアップデートtwitterボタン
:
$(document).ready(function() {
//get Quote And call to update twitter Button
$.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(a) {
$("#quote-content").html(a[0].content);
$("#quote-title").text(a[0].title);
updateTweet(a);
});
//new Quote and update Twitter
$('#newButton').on('click', function() {
$.ajax({
url: 'https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=',
success: function(a) {
$('#quote-content').html(a[0].content);
$('#quote-title').text(a[0].title);
updateTweet(a);
},
cache: false
});
});
//update twitter button function
function updateTweet(a) {
var thisQuote = a[0].content.replace(/<\/?[^>]+(>|$)/g, "");
var thisQuoteTitle = a[0].title;
$(".twitter-share-button").attr("href", "https://twitter.com/intent/tweet?text=" + thisQuote + "- " + thisQuoteTitle);
}
});
は、ここで私はこれに取り組んでいます私のcodepenです。どんな助けもありがとう。申し訳ありませんが、これは私はまだJavaScriptを学習し、物事多くのことを忘れて、含めるのを忘れていくつかの愚かな事なら...
甘い!どうもありがとうございます!! – Uberche
@Ubercheよろしくお願いします!それが役に立つと分かった場合は、私の答えを正解とすることができることを忘れないでください。あなたの将来のコーディング努力に幸運を祈る! – trevor
私はできると思っていましたが、私の脳は明らかにうまく機能していないので、どのようにして理解できませんでした。それをどうやって行うのですか? 問題が見つかりません。 – Uberche