user6729767
user6729767

Reputation:

jQuery button doesn't work on first click, only second

Hello I am playing with code whilst learning jQuery and I can't figure out how to make the Login button to work on first click. At the moment it works only on second click.

$('#login').on({
  'click': function() {

    $('#duck').attr('src', rand);
    if (login_username.value !== 'Endra') {
      $('.login').toggleClass('animated shake');
      $('.babe').html("Hello unknown,enter a name.");

    }

CodePen Link

Upvotes: 0

Views: 677

Answers (1)

Puroto
Puroto

Reputation: 153

You have a ".click" to call the function and further in your code, you have a second ".click" for your primary button.

just remove it ;)

//$('.btn-primary').on('click', function() {

    $('.content').css('display', 'inline').addClass('animated flipInX'); //Change animation for login
//});

Upvotes: 1

Related Questions