0
我有這個codePen這是一個隨機報價發生器。 我也有一個鳴叫按鈕,應該鳴叫生成的報價。 當前按下它時,它會鳴叫另一個隨機報價,而不是當前顯示的報價。下面是函數:按鈕沒有正確地發短信
$(".twitter-share-button").click(function(){
$(this).attr("href", 'https://twitter.com/intent/tweet?text=' + randomNumber);
});
function tweetIt(){
var randomNumber = Math.floor(Math.random() * (quotes.length));
window.open("https://twitter.com/intent/tweet?text=" + quotes[randomNumber]);
}
我試圖通過選擇電流ID的報價是但無濟於事解決這個:
function tweetIt(){
var tweet = document.getElementById('quote').value;
window.open("https://twitter.com/intent/tweet?text=" + quotes[randomNumber]);
};
任何幫助,這將不勝感激。
請勿使用'innerText'。這不是標準的,並且不存在於FireFox中。使用'textContent'。 – Barmar
謝謝你解釋清楚。另外,謝謝@Barmar – YoungCoder
@Barmar謝謝你,我也調整了答案。 –