Avatar of Eduardo Fuerte
Eduardo Fuerte
Flag for Brazil

asked on 

How to use the same jquery code in two diferents parts of the same page?

Hi Experts

I need to use a the same code  in 02 parts of the same page with diferente contents:

My page use this tab near the top

         <ul class="tabs">
         <li><a href="#tab1" class="selected"> O que &eacute; ?</a></li>
         <li><a href="#tab2">PPAIS</a></li>
         <li><a href="#tab3">PNAE</a></li>

        <div class="tab" id="tab1" style="display: block;">
                <p style="text-align:justify"> Texto descritivo o que é ?</p>
        <div class="tab" id="tab2">
        <p>Texto descritivo do PPAIS</p>
        <div class="tab" id="tab3">
        <p>Texto descritivo do PNAE</p>

$(function() {
  $('ul.tabs li a').click(function(e) {
    if (!$(this).hasClass('selected')) {

Open in new window

I need to use it again in the botton part of the page (another similar tab with other content)

What must be changed in the 2nd use of the tab?

Thanks in advance!

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon