title: Get 'data-id' property value via JQuery
body: <p>I have the following HTML code (I'm using Bootstrap Twitter Modal):</p>
  
  <pre><code> &lt;a href='#' data-toggle='modal' data-target='#myModal' id='g' data-id=1&gt;Launch modal&lt;/a&gt;
  
  &lt;div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&gt;
    &lt;div class="modal-dialog"&gt;
      &lt;div class="modal-content"&gt;
        &lt;div class="modal-header"&gt;
          &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&amp;times;&lt;/button&gt;
          &lt;h4 class="modal-title" id="myModalLabel"&gt;Modal title&lt;/h4&gt;
        &lt;/div&gt;
        &lt;div class="modal-body"&gt;
          ...
  
        &lt;/div&gt;
        &lt;div class="modal-footer"&gt;
          &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
          &lt;button type="button" class="btn btn-primary"&gt;Save changes&lt;/button&gt;
        &lt;/div&gt;
      &lt;/div&gt;&lt;!-- /.modal-content --&gt;
    &lt;/div&gt;&lt;!-- /.modal-dialog --&gt;
  &lt;/div&gt;&lt;!-- /.modal --&gt;
  </code></pre>
  
  <p>And the following JQuery code:</p>
  
  <pre><code>   &lt;script&gt;
                $('#g').click(function () {
                    alert($(this).data("id"));
                });
     &lt;/script&gt; 
  </code></pre>
  
  <p>I want that onclick the link, after the bootstrap modal will open, there will be alrt with the 'data-modal' value.</p>
  
  <p>I tried the code above and it didn't work.</p>
  
  <p>My question is how can I fix it? (I'm pretty new with JQuery...) </p>