JSFiddle - React, Tailwind, and code Playground

by Timmy Willison

HTML

<div>Swapping is helpful!</div>
<span></span>

CSS

div { position: absolute; top: 150px; left: 45px; display: none; width: 110px; height: 50px; }

JavaScript

// Temporarily swap visibility instead of display: none to get correct top/left in firefox 3
var top, left, div = $('div'), span = $('span');
top = div.css('top');
left = div.css('left');

span.text('before swap div top: ' + top + '  before swap div left: ' + left);
          
$.swap(div[0],
   {
       "display": "block", 
       "visibility": "hidden"
   },
   function() {
       top = div.css('top');
       left = div.css('left'); 
   }
);

div.text('div top: ' + top + '  div left: ' + left).show();