Jquery tabs elements with same id

admin

Administrator
Staff member
I am working with wordpress and jquery tabs and was wondering if somebody can help me. My example is similar to this one <a href="https://jqueryui.com/tabs/" rel="nofollow">jQuery UI Tabs</a>

Here is my php code

Code:
&lt;?php if (!defined('FW')) die( 'Forbidden' ); ?&gt;
&lt;?php $tabs_id = uniqid('fw-image-tabs-'); ?&gt;
    &lt;div class="fw-image-tabs-container" id="&lt;?php echo esc_attr($tabs_id); ?&gt;"&gt;
        &lt;div class="fw-image-tabs"&gt;
            &lt;?php foreach ($atts['image_tabs'] as $key =&gt; $tab) : ?&gt;
                &lt;div class="fw-image-tabs-content" id="&lt;?php echo esc_attr($tabs_id . '-' . ($key + 1)); ?&gt;"&gt;
                    &lt;h3 class="fw-image-tabs-content"&gt;&lt;?php echo $tab['tab_image_title']; ?&gt;&lt;/h3&gt;
                    &lt;img src="&lt;?php echo esc_attr( $tab['tab_image']['url']); ?&gt;"&gt;
                &lt;/div&gt;
            &lt;?php endforeach; ?&gt;

            &lt;ul&gt;
                &lt;?php foreach ($atts['image_tabs'] as $key =&gt; $tab) : ?&gt;
                    &lt;li&gt;&lt;a href="#&lt;?php echo esc_attr($tabs_id . '-' . ($key + 1)); ?&gt;"&gt;&lt;?php echo $tab['tab_title']; ?&gt;&lt;/a&gt;&lt;/li&gt;
                &lt;?php endforeach; ?&gt;
            &lt;/ul&gt;

            &lt;?php foreach ( $atts['image_tabs'] as $key =&gt; $tab ) : ?&gt;
                &lt;div class="fw-image-tabs-content" id="&lt;?php echo esc_attr($tabs_id . '-' . ($key + 1)); ?&gt;"&gt;
                    &lt;p&gt;&lt;?php echo do_shortcode( $tab['tab_content'] ) ?&gt;&lt;/p&gt;
                &lt;/div&gt;
            &lt;?php endforeach; ?&gt;
        &lt;/div&gt;
    &lt;/div&gt;

And my script

Code:
jQuery(document).ready(function ($) {
    $('.fw-image-tabs-container').tabs();
});

The trouble i am having is that i cannot hide the second
Code:
&lt;div class="fw-image-tabs-content"&gt;&lt;/div&gt;
. Both divs have the same class name and the same id. For some reason only the first id works. How can i show/hide the text for both divs?

Thanks