Good evening! I already asked a question about "Hiding blocks using jquery" and got the right answer to it.

`Good evening! Baseline: a catalog of products, each product of which is displayed on the page below each other. The problem is as follows: It is necessary that the goods are displayed in the form of a list and some β€œ+” tags (for example, β€œHousehold goods 1, [+]”), when clicked, a block with information about a specific product was opened. It is also necessary to have the function "hide all blocks" and "reveal all blocks."

I would be grateful if you tell in which direction to dig (jqueryui dug, but did not understand) or throw a link to an already implemented example.`

The answer was the following:

<script type="text/javascript"> $(document).ready(function () { $('.showinfo').click(function () { // ΠΏΡ€ΠΈ ΠΊΠ»ΠΈΠΊΠ΅ Π½Π° .showinfo скрываСм/раскрываСм Π±Π»ΠΎΠΊ с ΠΈΠ½Ρ„ΠΎΠΉ $(this).parent().find('.productinfo').toggle(); $(this).text($(this).text() == 'ΠΏΠΎΠΊΠ°Π·Π°Ρ‚ΡŒ' ? 'ΡΠΊΡ€Ρ‹Ρ‚ΡŒ' : 'ΠΏΠΎΠΊΠ°Π·Π°Ρ‚ΡŒ'); return false; }); $('#hide-all').click(function () { // ΠΏΡ€ΠΈ ΠΊΠ»ΠΈΠΊΠ΅ Π½Π° #hide-all скрываСм всС Π±Π»ΠΎΠΊΠΈ, мСняСм тСксты ΠΊΠ½ΠΎΠΏΠΎΠΊ $('.productinfo').hide('slow'); $('.showinfo').text('ΠΏΠΎΠΊΠ°Π·Π°Ρ‚ΡŒ'); return false; }); $('#show-all').click(function () { // ΠΏΡ€ΠΈ ΠΊΠ»ΠΈΠΊΠ΅ Π½Π° #show-all раскрываСм всС Π±Π»ΠΎΠΊΠΈ, мСняСм тСксты ΠΊΠ½ΠΎΠΏΠΎΠΊ $('.productinfo').show('slow'); $('.showinfo').text('ΡΠΊΡ€Ρ‹Ρ‚ΡŒ'); return false; }); }); </script> <a href="#" id="hide-all">Π‘ΠΊΡ€Ρ‹Ρ‚ΡŒ всС</a> <a href="#" id="show-all">Π Π°ΡΠΊΡ€Ρ‹Ρ‚ΡŒ всС</a> <div id="product-15" class="product"> <!-- ΠΊΠΎΠ΄ --> <div class="productinfo" style="display: none;">тСкст с описаниС ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚Π°</div> <a href="#" class="showinfo">ΠΏΠΎΠΊΠ°Π·Π°Ρ‚ΡŒ</a> </div> 

Now the task is complicated. It is necessary that there were not two buttons "Hide All" and "Expand All", but one that would perform the same functions and change its name accordingly when clicked.

    1 answer 1

    Or maybe try to complicate yourself? Moreover, the solution provided to you is quite visual. The idea is this: now, instead of clicks on each of the buttons (hide-show), you only need to track clicks by one. You have everything (and changing the name of the button and displaying / hiding the blocks). Take a closer look.

    • one
      IMHO for one button it is even easier to write - Zowie
    • five
      damn, that's if everyone will look at the latest topics. 1. "Learning PHP programming language" 2. "What is the best way to write websites?" 3. "Where to continue training school programmer (Moscow)?" 4. "Choosing a programming language for the future [closed]" 5. "Becoming a professional." etc. a lot of them especially in the last week. It affects me that in a year there will be questions like: β€œI started writing a website. With these thoughts I finished, tell me what to write it with, what program, and how much you can take from the customer. Considering that this is my first website.” He studied in St. Petersburg ITMO, in phil. but wanted to be a programmer. - Artem
    • On these thoughts and finished: DDD - Zowie