0

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

2
  • Works the first time for me in your CodePen Commented Aug 18, 2016 at 14:35
  • Not when I try to login with username set to 'Endra' ,I have to click twice. Commented Aug 18, 2016 at 14:38

1 Answer 1

1

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
//});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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