Semantic interface not open

I am using semantic interface and created a button with an event click

that should open the modal on click, but nothing happens.

Nothing happens when I click on the link, I don't know what is going wrong.

Here is the button:

<a class="item" id="logIn">
    <i class="user icon"></i> Log In 
</a>

      

JavaScript:

 <script type="text/javascript">

  $('#logIn').click(function(){
    $('#modaldiv').modal('show');    
  });

  </script>

      

Modal code:

<div id="modaldiv" class="ui modal">
  <i class="close icon"></i>
  <div class="header">
    Profile Picture
  </div>
  <div class="content">
    <div class="ui medium image">
      <img src="/images/avatar/large/chris.jpg">
    </div>
    <div class="description">
      <div class="ui header">We've auto-chosen a profile image for you.</div>
      <p>We've grabbed the following image from the <a href="https://www.gravatar.com" target="_blank">gravatar</a> image associated with your registered e-mail address.</p>
      <p>Is it okay to use this photo?</p>
    </div>
  </div>
  <div class="actions">
    <div class="ui black button">
      Nope
    </div>
    <div class="ui positive right labeled icon button">
      Yep, that me
      <i class="checkmark icon"></i>
    </div>
  </div>
</div>

      

+3


source to share


3 answers


You may be binding the event path before the DOM is ready, so try with completing your code in the finished document:

$(document).ready(function(){
     $('#logIn').click(function(){
        $('#modaldiv').modal('show');    
     });
});

      




Another thing, you can check for errors in the browser console, which will help you understand the problems.

+3


source


Jai's solutions worked for me as well. I used id instead of classes for selection.



+1


source


Make sure you put your jquery

script before the semantics

<script src="scripts/jquery.js"></script>
<script src="scripts/semantic.js"></script>

      

0


source







All Articles