Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.95 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to use position in CSS?
  2. <table id="tab">
  3.     <tr><td class="here">dgd</td><td class="here">dfg</td></tr>
  4.     <tr><td class="here">fgf</td><td class="here">sg4</td></tr>
  5. </table>
  6.  
  7.  
  8. <table id="new">
  9.     <tr><td id="al">sss</td></tr>
  10. </table>
  11.  
  12. #tab td {
  13.   padding: 5px;
  14.   border: solid 1px red;
  15. }
  16.  
  17. #new td {
  18.     padding: 5px;
  19.     height: 40px;
  20.       border: solid 1px green;
  21.     background-color: green;
  22. }
  23.  
  24. #new {
  25.     display: none;
  26. }
  27.  
  28. $(".here").click(function(){
  29.    $("#new").show();
  30. })
  31.  
  32.     $("#al").click(function(){
  33.        alert('ok');
  34.     })
  35.        
  36. $('.item').click(function(event){
  37.     $('#context').show();
  38.     event.stopPropogation();
  39. });
  40. $('body').click(function(){
  41.     $('#context').hide();
  42. });
  43.        
  44. $(document).on("click", function(e) {
  45.     var $el = $(e.target);
  46.     if ($el.hasClass("here")) {
  47.         $("#new").css({'left': e.target.offsetLeft,
  48.                        'top': e.target.offsetTop}).show();
  49.     } else {
  50.         $("#new").hide();
  51.     }
  52. });