0

I am struggling with targeting markup that is rendered by a plugin. I am using this plugin:

http://jellekralt.github.io/Responsive-Tabs/demo/demo.html

You will find the site here:

kenaesthetic.com

I am trying to target the #infotabs a selector but there seems to be a disconnect. The plugin takes my initial markup and re-renders it. I now need to target the generated markup but seem unable. How is this done?

1
  • 1
    Always include the relevant code and markup (and DOM screenshots, in this case) in the question, don't just link. Links rot, and people shouldn't have to go off-site to help you. Commented Apr 9, 2014 at 17:35

2 Answers 2

2

You need to use event delegation. You would put the listener on the parent of the dynamically created markup and wait for the event to bubble up.

$('.holds-html-generated-by-plugin').on('click', '.generated-by-plugin', function () {
  // this will be '.generated-by-plugin'
  console.log(this);
});
Sign up to request clarification or add additional context in comments.

Comments

1

The plugin's documentation should tell you what you need to know about how it changes the DOM. If it doesn't, it's poorly-documented.

If the plugin is poorly-documented, the basic approach (if you want to use it) is to apply the plugin to your page and use the tools built into your browser to see how it changes the DOM. All modern browsers have a set of quite useful tools built into them; look through the menus (or press F12, which is emerging as the standard keystroke for opening them).

Once you know how the plugin changes the DOM, you can write selectors to target the changes. Be sure you don't try to use those selectors until after the plugin has applied its changes, as they won't be relevant yet. So either don't use them until the plugin has done its thing, or use them in delegated handlers.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.