Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

jQuery Swap Images

I recently made a post for swapping images.  The answer was great.  However, I have a similar question;

I need to swap a plus sign and a minus sign where there is a view more link.  The link toggles open and close a section:

<script>
<script>
$(function() {
  $('.viewmore').click(function(e) {
    e.preventDefault();
    $(this).closest('ul').find('.sublinks').toggleClass('noshow');
    var text =  ($(this).text() == 'View All') ? '-' : '+';
    $(this).html(text);
  });
});
</script>

</script>

<html>
 <ul class="nav">
        <li><a href="#" class="viewmore"> View All</a>
          <ul style="display: none" class="nav">
            <li><a href="#">Option 1</a></li>
            <li><a href="#">Option 2</a></li>
            <li><a href="#">Option 3</a></li>
          </ul>
        </li>
      </ul>
</html>

Open in new window

I want to remove the "View All"  and replace with a + (Plus Sign) and toggle back and forth between a plus and minus sign.

The Menu is not hard coded, it is in a CMS so I can't hard code it and the menu choice (without a link) , has to have a title
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial