0

I am using a jQuery UI Tabs widget that exists within an iframe on the page. From the parent document, I need to be able to access the tabs object and use its methods (the 'select' method in particular). I am using the following code currently:

var iframe = $('#mainFrame').contents().get(0);
$('#tabs', iframe).tabs('select', 1);

The code does not throw any errors/warnings in the console and the jquery object for $('#tabs', iframe) does seem to be selecting the correct elements from the DOM of the iframe, however nothing happens when this is executed.

2 Answers 2

2

You're turning the jQuery object reference into a DOM node by calling .get(0). Try instead:

var iframe = $('#mainFrame').contents();
iframe.find('#tabs').tabs('select', 1);

ref.: .find()

Sign up to request clarification or add additional context in comments.

Comments

0

You could try (untested):

$('#mainFrame').contents().find('#tabs').tabs('select', 1);

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.