troubleshooting Question

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

Avatar of Eduardo Fuerte
Eduardo FuerteFlag for Brazil asked on
3 Comments1 Solution83 ViewsLast Modified:
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')) {

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!
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros