The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Small jQuery plugin dilemma Reply To: Small jQuery plugin dilemma


Indeed. It’s a plugin — I have no control over what the user did to the page where he/she wants to include the plugin.

This is how it works. Let’s say someone uses my plugin on their own page. Obviously, I don’t have any control over the code of this page. Good or bad.

My plugin creates a clone of an element. This cloned element HAS to have the exact same styles as the original element. All of them. Because it has to look exactly the same.

If the original element was styled by the author only with classes as selectors, fine. The clone will have the same classes then, and so will look the same.

But if the original element was styled by the author with the ID as selector, the only way to make the cloned element look the same is if it would have the same ID as well.

It’s fine if the sticky element HAS an ID. It’s not if the sticky element has been STYLED with the ID as a selector.


  • Option 1: give the cloned element the same ID, or…
  • Option 2: cloned element will not get an ID and say “this plugin does not support elements that have been styled using an ID as selector“, or…
  • Option 3: “read” all styles from the original element (how??) and apply them all to the cloned element (with a new class)