0

First make sure you are looking at the jQuery UI .position. https://api.jqueryui.com/position/

I have been assigned to remove the whole jQuery library from the site. I have removed it all, except for 2 functions.

This is the original code section which includes .position before I started changing things:

   if (thingType == "story") {
      $(voterEl).closest("li").after(dropDownDiv);
      dropDownDiv.position({
        my: "left top",
        at: "left bottom",
        offset: "-2 -2",
        of: $(voterEl),
        collision: "none",
      });
      dropDownDiv.css("left", $(voterEl).position().left);
    } else {
      // place flag menu outside of the comment to avoid inheriting opacity
      var voterPos = $(voterEl).position();
      dropDownDiv.appendTo($(voterEl).parent());
      dropDownDiv.css({
        left: voterPos.left,
        top: voterPos.top + $(voterEl).outerHeight()
      });
    }

Does anyone know a simple way to create a div with a relative position to another element via JavaScript? I can change CSS, but I am restricted in that I can't change any HTML, unless I can add it through the javascript.

YmeYnot45
  • 1
  • 2
  • Just for the record, anything that's in jquery or jquery ui can be done with javascript, as those libraries are written in javascript. If you take a look [here](https://github.com/davidjamesstone/jquery.ui.position/blob/master/jquery-ui.js) you can see that an implementation of the `position` function is rather complex, or at least rather long, and so whilst it can be implemented it may be better to either see if you can achieve the effect some other way, or to copy an existing implementation (such as the one linked there) – OliverRadini Jul 13 '22 at 19:23
  • Check out this codepen: https://codepen.io/dylan9o4/pen/KKwmzQx?editors=1111 – imvain2 Jul 13 '22 at 19:26

0 Answers0