Hi all I am trying to add a class selected to click area and a remove class in the hide area for the below jquery/javascript. Not really undstanding how it's added.

Thanks in advaance

D

  <script type="text/javascript">
        $(document).ready(function(){
            $('.partner_image').click(function() {
               var id =$(this).class('selected');
               var id = $(this).attr('id');
               id = id.replace('partner_','');
               console.log(id);

              $('.partner_description').hide();
              var description = $('#partner_description_' + id);
              $(description).show();
                });

            });

        </script>

Hi EvolutionFallen thanks for the reply I have added the elements in bold don't seem to work yet am I on the correct track.

Thanks in advance

D

 <script type="text/javascript">
        $(document).ready(function(){
            $('.partner_image').click(function() {
               var id = $(this).attr('id');
               id = id.replace('partner_','');
              ** $(this).addClass("selected"); **
               console.log(id);

             $('.partner_description').hide();
              var description = $('#partner_description_' + id);
             ** $(this).removeClass("selected"); **
              $(description).show();
                });
            });
        </script>

Can you show the HTML, and indicate what you're trying to show/hide?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.