2017-11-08 17 views
0

jsをhtmlにリンクしようとしているので、ユーザーがtweetアイコンをクリックすると、自動的にtwitterボックスにtwitterボックスが埋め込まれます...それを満たしていない...任意の提案?javascriptの自動tweet fill(quote)が正しく動作しない

function makeId() { 
    var rNumber = Math.floor(Math.random() * quotes.length); 
    $("#quote > h1").html(quotes[rNumber]); 
} 
$("#press").on('click', function() { 
    $("#quote > h1").fadeOut('slow', function(){ 
    makeId(); 
    $(this).fadeIn('slow'); 
}); 
}); 
$("#icon > a").click(function(){ 
    window.open("https://twitter.com/intent/tweet?text=" + makeId()); 
}) 

私の全体のコードはここにある - https://codepen.io/buzz_lightyear/pen/gXLLpo?editors=1010

+1

に置き換えてください)機能 –

答えて

1

私の代わりに、あなたがURLに現在のIDの値を追加するために必要な新しいIDを選択/作成する、あなたのためにそれを修正しました。

$("#icon > a").click(function(){ 
    window.open("https://twitter.com/intent/tweet?text=" + makeId()); 
}) 

はあなたがmakeId(から何かを返す必要があります

$("#icon > a").click(function(){ 
    window.open("https://twitter.com/intent/tweet?text=" + $("#quote > h1").html()); 
}) 
+0

それは働いていない...私は取得していますすべては、空のつぶやきボックスではなく、その中に引用され –

+0

私はあなたのcodepenを編集し、それは動作します。再実行ボタンを押しましたか? –

+0

はい...変更なし –

関連する問題