0

I am trying to display random text in array for every button click. Couldn't figureout whats going wrong. Help me if you can solve it.

 $(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();
});
});

https://jsfiddle.net/hq7mv2zv/

1 Answer 1

1

Maybe this will work:

I've removed the onclick from the button and updated $("#btn").on(click, function(){ to $("#btn").on('click', function(){

https://jsfiddle.net/hq7mv2zv/1/

Sign up to request clarification or add additional context in comments.

1 Comment

Oh, My bad . Thank you so much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.