Jump to content

Changing "minus" sign into "plus" sign


Go to solution Solved by codefossa,

Recommended Posts

Hi All,

 

I have a list of countries, with a sublist of cities associated with each country. There is also an associate + or - sign associated with each country name. When I click the minus sign, the associated list closes and the minus sign converts to plus sign. The reverse works also.

 

I also have a global "-" sign that when clicked collapses all the data, leaving just the country names displayed, and converts to a plus sign. This will enable the user to scroll down the data until the desired country without having to see the cities of countries that are higher in the list. The reverse works also : when the global plus sign is clicked, all data are displayed.

 

My problem is the following. If I click the global minus sign, I would like any minus signs associated with countries to appear as "+" signs. And if I click the global plus sign, I would like any plus signs associated with countries to appear as "-" signs.

 

 

Here is jsfiddle for your convience : http://jsfiddle.net/qX6k8/

 

Thanks a lot you for your help.

 

 

Link to comment
https://forums.phpfreaks.com/topic/278672-changing-minus-sign-into-plus-sign/
Share on other sites

I'd start by restructuring your DOM; at the moment you have no encapsulation for each expandable section. Consider wrapping each section in a div and then using a single span to wrap the titles with an additional span tag around the [-/+] parts.

 

You can then write your JavaScript using the top node in each section, i.e. using the div that encapsulates each section, to manipulate the content within. I'd also suggest registering your event listeners in your JavaScript as opposed to inline although its not a big issue either way.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.