0

Welcome, I have this code: html:

<script src="loginbox.js"></script>
<div class="menu" id="login">
      <p class="menu">LOG IN</p>
    </div>

js:

  $('#login').on('click', function(){
  document.getElementById('login').hide();
});

The div "login" isn't even clickable

Sleeper
  • 65
  • 1
  • 8

1 Answers1

1

Here you go :

$(document).ready(function(){
  $('#login').on('click', function(){
    $(document.getElementById('login')).hide();
  });
});

When you mix pure JS and jQuery, you need to wrap pure JS in a jQueryObject.

PS: I'd swap the $(document.getElementById('login')) for a $("#login") if I were you

Vivick
  • 3,434
  • 2
  • 12
  • 25
  • still doesn't work, + document is red in my text editor, I think it's something with this – Sleeper Apr 15 '17 at 20:39
  • https://jsfiddle.net/Voltra/ugwkfffn/ Maybe you just did not include jQuery – Vivick Apr 15 '17 at 20:43
  • Yes I didnt, now it works Do you know how to add "button cursor"? when cursor is on div "login", it becomes "button cursor", you know, when cursor is on button – Sleeper Apr 15 '17 at 20:51
  • then just add : `#login:hover{ cursor:pointer; }` In your css file – Vivick Apr 15 '17 at 20:54