我试图在每次点击按钮时在数组中显示随机文本。 无法弄清楚什么是错的。如果你能解决它,请帮助我。
$(window).ready(function(){
function quot(){
var quotes="Currently a Graduate Student in the Department of Computer Science at Northern Illinois University.@ A great lover of web programming, in search of an full-time oppurtunity to showbiz my skills and more prominently to develop myself into a master in web programming.@Apart from programming and related stuff, i play and follow sports a lot.@ I am a great soccer and cricket follower. Currently i am part of the Northern Illinois University Huskies Cricket Team that won the Midwest Regional Championship 2015.@I have great passion towards solo travelling too.";
var newArray=quotes.split("@");
var min=1;
var max=newArray.length-1;
var number=Math.floor(Math.random()*(max-min+1))+min;
$("#demo").text(newArray[number]);
}
quot();
$("#btn").on(click, function(){
quot();
});
});
答案 0 :(得分:1)
也许这会奏效:
我已从按钮中移除onclick
并将$("#btn").on(click, function(){
更新为$("#btn").on('click', function(){