Implement toggle display between items in AMP










1















How can I show just one item on tap event?



I need to set other items false when one item clicked.



Now I change <li> class when child <a> has been tapped.






.megamenu-item .dropdpwn-links
display:none;


.megamenu-item.show .dropdpwn-links
display:block;

<ul>
<li class="megamenu-item" [class]="megamenuSubVisible && item1.show ? 'megamenu-item show' : 'megamenu-item'">
<a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item1: show:true )">open dropdown</a>
<div class="dropdpwn-links">
<div>item1</div>
<div>item2</div>
<div>item3</div>
<div>item4</div>
</div>
</li>
<li class="megamenu-item" [class]="megamenuSubVisible && item2.show ? 'megamenu-item show' : 'megamenu-item'">
<a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item2: show:true )">open dropdown</a>
<div class="dropdpwn-links">
<div>item1</div>
<div>item2</div>
<div>item3</div>
<div>item4</div>
</div>
</li>
<li class="megamenu-item" [class]="megamenuSubVisible && item3.show ? 'megamenu-item show' : 'megamenu-item'">
<a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item3: show:true )">open dropdown</a>
<div class="dropdpwn-links">
<div>item1</div>
<div>item2</div>
<div>item3</div>
<div>item4</div>
</div>
</li>
</ul>





/********************************************************************************************/










share|improve this question




























    1















    How can I show just one item on tap event?



    I need to set other items false when one item clicked.



    Now I change <li> class when child <a> has been tapped.






    .megamenu-item .dropdpwn-links
    display:none;


    .megamenu-item.show .dropdpwn-links
    display:block;

    <ul>
    <li class="megamenu-item" [class]="megamenuSubVisible && item1.show ? 'megamenu-item show' : 'megamenu-item'">
    <a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item1: show:true )">open dropdown</a>
    <div class="dropdpwn-links">
    <div>item1</div>
    <div>item2</div>
    <div>item3</div>
    <div>item4</div>
    </div>
    </li>
    <li class="megamenu-item" [class]="megamenuSubVisible && item2.show ? 'megamenu-item show' : 'megamenu-item'">
    <a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item2: show:true )">open dropdown</a>
    <div class="dropdpwn-links">
    <div>item1</div>
    <div>item2</div>
    <div>item3</div>
    <div>item4</div>
    </div>
    </li>
    <li class="megamenu-item" [class]="megamenuSubVisible && item3.show ? 'megamenu-item show' : 'megamenu-item'">
    <a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item3: show:true )">open dropdown</a>
    <div class="dropdpwn-links">
    <div>item1</div>
    <div>item2</div>
    <div>item3</div>
    <div>item4</div>
    </div>
    </li>
    </ul>





    /********************************************************************************************/










    share|improve this question


























      1












      1








      1


      1






      How can I show just one item on tap event?



      I need to set other items false when one item clicked.



      Now I change <li> class when child <a> has been tapped.






      .megamenu-item .dropdpwn-links
      display:none;


      .megamenu-item.show .dropdpwn-links
      display:block;

      <ul>
      <li class="megamenu-item" [class]="megamenuSubVisible && item1.show ? 'megamenu-item show' : 'megamenu-item'">
      <a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item1: show:true )">open dropdown</a>
      <div class="dropdpwn-links">
      <div>item1</div>
      <div>item2</div>
      <div>item3</div>
      <div>item4</div>
      </div>
      </li>
      <li class="megamenu-item" [class]="megamenuSubVisible && item2.show ? 'megamenu-item show' : 'megamenu-item'">
      <a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item2: show:true )">open dropdown</a>
      <div class="dropdpwn-links">
      <div>item1</div>
      <div>item2</div>
      <div>item3</div>
      <div>item4</div>
      </div>
      </li>
      <li class="megamenu-item" [class]="megamenuSubVisible && item3.show ? 'megamenu-item show' : 'megamenu-item'">
      <a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item3: show:true )">open dropdown</a>
      <div class="dropdpwn-links">
      <div>item1</div>
      <div>item2</div>
      <div>item3</div>
      <div>item4</div>
      </div>
      </li>
      </ul>





      /********************************************************************************************/










      share|improve this question
















      How can I show just one item on tap event?



      I need to set other items false when one item clicked.



      Now I change <li> class when child <a> has been tapped.






      .megamenu-item .dropdpwn-links
      display:none;


      .megamenu-item.show .dropdpwn-links
      display:block;

      <ul>
      <li class="megamenu-item" [class]="megamenuSubVisible && item1.show ? 'megamenu-item show' : 'megamenu-item'">
      <a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item1: show:true )">open dropdown</a>
      <div class="dropdpwn-links">
      <div>item1</div>
      <div>item2</div>
      <div>item3</div>
      <div>item4</div>
      </div>
      </li>
      <li class="megamenu-item" [class]="megamenuSubVisible && item2.show ? 'megamenu-item show' : 'megamenu-item'">
      <a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item2: show:true )">open dropdown</a>
      <div class="dropdpwn-links">
      <div>item1</div>
      <div>item2</div>
      <div>item3</div>
      <div>item4</div>
      </div>
      </li>
      <li class="megamenu-item" [class]="megamenuSubVisible && item3.show ? 'megamenu-item show' : 'megamenu-item'">
      <a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item3: show:true )">open dropdown</a>
      <div class="dropdpwn-links">
      <div>item1</div>
      <div>item2</div>
      <div>item3</div>
      <div>item4</div>
      </div>
      </li>
      </ul>





      /********************************************************************************************/






      .megamenu-item .dropdpwn-links
      display:none;


      .megamenu-item.show .dropdpwn-links
      display:block;

      <ul>
      <li class="megamenu-item" [class]="megamenuSubVisible && item1.show ? 'megamenu-item show' : 'megamenu-item'">
      <a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item1: show:true )">open dropdown</a>
      <div class="dropdpwn-links">
      <div>item1</div>
      <div>item2</div>
      <div>item3</div>
      <div>item4</div>
      </div>
      </li>
      <li class="megamenu-item" [class]="megamenuSubVisible && item2.show ? 'megamenu-item show' : 'megamenu-item'">
      <a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item2: show:true )">open dropdown</a>
      <div class="dropdpwn-links">
      <div>item1</div>
      <div>item2</div>
      <div>item3</div>
      <div>item4</div>
      </div>
      </li>
      <li class="megamenu-item" [class]="megamenuSubVisible && item3.show ? 'megamenu-item show' : 'megamenu-item'">
      <a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item3: show:true )">open dropdown</a>
      <div class="dropdpwn-links">
      <div>item1</div>
      <div>item2</div>
      <div>item3</div>
      <div>item4</div>
      </div>
      </li>
      </ul>





      .megamenu-item .dropdpwn-links
      display:none;


      .megamenu-item.show .dropdpwn-links
      display:block;

      <ul>
      <li class="megamenu-item" [class]="megamenuSubVisible && item1.show ? 'megamenu-item show' : 'megamenu-item'">
      <a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item1: show:true )">open dropdown</a>
      <div class="dropdpwn-links">
      <div>item1</div>
      <div>item2</div>
      <div>item3</div>
      <div>item4</div>
      </div>
      </li>
      <li class="megamenu-item" [class]="megamenuSubVisible && item2.show ? 'megamenu-item show' : 'megamenu-item'">
      <a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item2: show:true )">open dropdown</a>
      <div class="dropdpwn-links">
      <div>item1</div>
      <div>item2</div>
      <div>item3</div>
      <div>item4</div>
      </div>
      </li>
      <li class="megamenu-item" [class]="megamenuSubVisible && item3.show ? 'megamenu-item show' : 'megamenu-item'">
      <a href="" on="tap:AMP.setState(megamenuSubVisible: !megamenuSubVisible , item3: show:true )">open dropdown</a>
      <div class="dropdpwn-links">
      <div>item1</div>
      <div>item2</div>
      <div>item3</div>
      <div>item4</div>
      </div>
      </li>
      </ul>






      javascript html amp-html






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 13:05









      Vadim Kotov

      4,38953247




      4,38953247










      asked Nov 13 '18 at 11:22









      miladhpmiladhp

      2418




      2418






















          1 Answer
          1






          active

          oldest

          votes


















          1














          You can toggle the click item parent and set the value for others items parent






          <!doctype html>
          <html ⚡>
          <head>
          <meta charset="utf-8">
          <link rel="canonical" href="final.html">
          <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
          <style amp-boilerplate>body-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both@-webkit-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-moz-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-ms-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-o-keyframes -amp-startfromvisibility:hiddentovisibility:visible@keyframes -amp-startfromvisibility:hiddentovisibility:visible</style><noscript><style amp-boilerplate>body-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none</style></noscript>
          <script async src="https://cdn.ampproject.org/v0.js"></script>
          <script async custom-element="amp-selector" src="https://cdn.ampproject.org/v0/amp-selector-0.1.js"></script>
          <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
          <style amp-custom>
          .megamenu-item .dropdpwn-links
          display:none;


          .megamenu-item.show .dropdpwn-links
          display:block;

          </style>
          </head>
          <body>
          <ul>
          <li [class]="item1 ? 'show' : 'megamenu-item'" class="megamenu-item">
          <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item1: !item1,item2:megamenu-item,item3:megamenu-item)">open dropdown</a>
          <div class="dropdpwn-links">
          <div>item1</div>
          <div>item2</div>
          <div>item3</div>
          <div>item4</div>
          </div>
          </li>
          <li [class]="item2 ? 'show' : 'megamenu-item'" class="megamenu-item">
          <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item2: !item2,item1:megamenu-item,item3:megamenu-item)">open dropdown</a>
          <div class="dropdpwn-links">
          <div>item1</div>
          <div>item2</div>
          <div>item3</div>
          <div>item4</div>
          </div>
          </li>
          <li [class]="item3 ? 'show' : 'megamenu-item'" class="megamenu-item">
          <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item3: !item3,item2:megamenu-item,item1:megamenu-item)">open dropdown</a>
          <div class="dropdpwn-links">
          <div>item1</div>
          <div>item2</div>
          <div>item3</div>
          <div>item4</div>
          </div>
          </li>
          </ul>
          </body>
          </html>





          Note : in place of <a> tag you should use <span> tag






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279944%2fimplement-toggle-display-between-items-in-amp%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            You can toggle the click item parent and set the value for others items parent






            <!doctype html>
            <html ⚡>
            <head>
            <meta charset="utf-8">
            <link rel="canonical" href="final.html">
            <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
            <style amp-boilerplate>body-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both@-webkit-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-moz-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-ms-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-o-keyframes -amp-startfromvisibility:hiddentovisibility:visible@keyframes -amp-startfromvisibility:hiddentovisibility:visible</style><noscript><style amp-boilerplate>body-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none</style></noscript>
            <script async src="https://cdn.ampproject.org/v0.js"></script>
            <script async custom-element="amp-selector" src="https://cdn.ampproject.org/v0/amp-selector-0.1.js"></script>
            <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
            <style amp-custom>
            .megamenu-item .dropdpwn-links
            display:none;


            .megamenu-item.show .dropdpwn-links
            display:block;

            </style>
            </head>
            <body>
            <ul>
            <li [class]="item1 ? 'show' : 'megamenu-item'" class="megamenu-item">
            <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item1: !item1,item2:megamenu-item,item3:megamenu-item)">open dropdown</a>
            <div class="dropdpwn-links">
            <div>item1</div>
            <div>item2</div>
            <div>item3</div>
            <div>item4</div>
            </div>
            </li>
            <li [class]="item2 ? 'show' : 'megamenu-item'" class="megamenu-item">
            <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item2: !item2,item1:megamenu-item,item3:megamenu-item)">open dropdown</a>
            <div class="dropdpwn-links">
            <div>item1</div>
            <div>item2</div>
            <div>item3</div>
            <div>item4</div>
            </div>
            </li>
            <li [class]="item3 ? 'show' : 'megamenu-item'" class="megamenu-item">
            <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item3: !item3,item2:megamenu-item,item1:megamenu-item)">open dropdown</a>
            <div class="dropdpwn-links">
            <div>item1</div>
            <div>item2</div>
            <div>item3</div>
            <div>item4</div>
            </div>
            </li>
            </ul>
            </body>
            </html>





            Note : in place of <a> tag you should use <span> tag






            share|improve this answer



























              1














              You can toggle the click item parent and set the value for others items parent






              <!doctype html>
              <html ⚡>
              <head>
              <meta charset="utf-8">
              <link rel="canonical" href="final.html">
              <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
              <style amp-boilerplate>body-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both@-webkit-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-moz-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-ms-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-o-keyframes -amp-startfromvisibility:hiddentovisibility:visible@keyframes -amp-startfromvisibility:hiddentovisibility:visible</style><noscript><style amp-boilerplate>body-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none</style></noscript>
              <script async src="https://cdn.ampproject.org/v0.js"></script>
              <script async custom-element="amp-selector" src="https://cdn.ampproject.org/v0/amp-selector-0.1.js"></script>
              <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
              <style amp-custom>
              .megamenu-item .dropdpwn-links
              display:none;


              .megamenu-item.show .dropdpwn-links
              display:block;

              </style>
              </head>
              <body>
              <ul>
              <li [class]="item1 ? 'show' : 'megamenu-item'" class="megamenu-item">
              <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item1: !item1,item2:megamenu-item,item3:megamenu-item)">open dropdown</a>
              <div class="dropdpwn-links">
              <div>item1</div>
              <div>item2</div>
              <div>item3</div>
              <div>item4</div>
              </div>
              </li>
              <li [class]="item2 ? 'show' : 'megamenu-item'" class="megamenu-item">
              <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item2: !item2,item1:megamenu-item,item3:megamenu-item)">open dropdown</a>
              <div class="dropdpwn-links">
              <div>item1</div>
              <div>item2</div>
              <div>item3</div>
              <div>item4</div>
              </div>
              </li>
              <li [class]="item3 ? 'show' : 'megamenu-item'" class="megamenu-item">
              <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item3: !item3,item2:megamenu-item,item1:megamenu-item)">open dropdown</a>
              <div class="dropdpwn-links">
              <div>item1</div>
              <div>item2</div>
              <div>item3</div>
              <div>item4</div>
              </div>
              </li>
              </ul>
              </body>
              </html>





              Note : in place of <a> tag you should use <span> tag






              share|improve this answer

























                1












                1








                1







                You can toggle the click item parent and set the value for others items parent






                <!doctype html>
                <html ⚡>
                <head>
                <meta charset="utf-8">
                <link rel="canonical" href="final.html">
                <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
                <style amp-boilerplate>body-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both@-webkit-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-moz-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-ms-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-o-keyframes -amp-startfromvisibility:hiddentovisibility:visible@keyframes -amp-startfromvisibility:hiddentovisibility:visible</style><noscript><style amp-boilerplate>body-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none</style></noscript>
                <script async src="https://cdn.ampproject.org/v0.js"></script>
                <script async custom-element="amp-selector" src="https://cdn.ampproject.org/v0/amp-selector-0.1.js"></script>
                <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
                <style amp-custom>
                .megamenu-item .dropdpwn-links
                display:none;


                .megamenu-item.show .dropdpwn-links
                display:block;

                </style>
                </head>
                <body>
                <ul>
                <li [class]="item1 ? 'show' : 'megamenu-item'" class="megamenu-item">
                <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item1: !item1,item2:megamenu-item,item3:megamenu-item)">open dropdown</a>
                <div class="dropdpwn-links">
                <div>item1</div>
                <div>item2</div>
                <div>item3</div>
                <div>item4</div>
                </div>
                </li>
                <li [class]="item2 ? 'show' : 'megamenu-item'" class="megamenu-item">
                <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item2: !item2,item1:megamenu-item,item3:megamenu-item)">open dropdown</a>
                <div class="dropdpwn-links">
                <div>item1</div>
                <div>item2</div>
                <div>item3</div>
                <div>item4</div>
                </div>
                </li>
                <li [class]="item3 ? 'show' : 'megamenu-item'" class="megamenu-item">
                <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item3: !item3,item2:megamenu-item,item1:megamenu-item)">open dropdown</a>
                <div class="dropdpwn-links">
                <div>item1</div>
                <div>item2</div>
                <div>item3</div>
                <div>item4</div>
                </div>
                </li>
                </ul>
                </body>
                </html>





                Note : in place of <a> tag you should use <span> tag






                share|improve this answer













                You can toggle the click item parent and set the value for others items parent






                <!doctype html>
                <html ⚡>
                <head>
                <meta charset="utf-8">
                <link rel="canonical" href="final.html">
                <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
                <style amp-boilerplate>body-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both@-webkit-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-moz-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-ms-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-o-keyframes -amp-startfromvisibility:hiddentovisibility:visible@keyframes -amp-startfromvisibility:hiddentovisibility:visible</style><noscript><style amp-boilerplate>body-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none</style></noscript>
                <script async src="https://cdn.ampproject.org/v0.js"></script>
                <script async custom-element="amp-selector" src="https://cdn.ampproject.org/v0/amp-selector-0.1.js"></script>
                <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
                <style amp-custom>
                .megamenu-item .dropdpwn-links
                display:none;


                .megamenu-item.show .dropdpwn-links
                display:block;

                </style>
                </head>
                <body>
                <ul>
                <li [class]="item1 ? 'show' : 'megamenu-item'" class="megamenu-item">
                <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item1: !item1,item2:megamenu-item,item3:megamenu-item)">open dropdown</a>
                <div class="dropdpwn-links">
                <div>item1</div>
                <div>item2</div>
                <div>item3</div>
                <div>item4</div>
                </div>
                </li>
                <li [class]="item2 ? 'show' : 'megamenu-item'" class="megamenu-item">
                <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item2: !item2,item1:megamenu-item,item3:megamenu-item)">open dropdown</a>
                <div class="dropdpwn-links">
                <div>item1</div>
                <div>item2</div>
                <div>item3</div>
                <div>item4</div>
                </div>
                </li>
                <li [class]="item3 ? 'show' : 'megamenu-item'" class="megamenu-item">
                <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item3: !item3,item2:megamenu-item,item1:megamenu-item)">open dropdown</a>
                <div class="dropdpwn-links">
                <div>item1</div>
                <div>item2</div>
                <div>item3</div>
                <div>item4</div>
                </div>
                </li>
                </ul>
                </body>
                </html>





                Note : in place of <a> tag you should use <span> tag






                <!doctype html>
                <html ⚡>
                <head>
                <meta charset="utf-8">
                <link rel="canonical" href="final.html">
                <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
                <style amp-boilerplate>body-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both@-webkit-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-moz-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-ms-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-o-keyframes -amp-startfromvisibility:hiddentovisibility:visible@keyframes -amp-startfromvisibility:hiddentovisibility:visible</style><noscript><style amp-boilerplate>body-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none</style></noscript>
                <script async src="https://cdn.ampproject.org/v0.js"></script>
                <script async custom-element="amp-selector" src="https://cdn.ampproject.org/v0/amp-selector-0.1.js"></script>
                <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
                <style amp-custom>
                .megamenu-item .dropdpwn-links
                display:none;


                .megamenu-item.show .dropdpwn-links
                display:block;

                </style>
                </head>
                <body>
                <ul>
                <li [class]="item1 ? 'show' : 'megamenu-item'" class="megamenu-item">
                <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item1: !item1,item2:megamenu-item,item3:megamenu-item)">open dropdown</a>
                <div class="dropdpwn-links">
                <div>item1</div>
                <div>item2</div>
                <div>item3</div>
                <div>item4</div>
                </div>
                </li>
                <li [class]="item2 ? 'show' : 'megamenu-item'" class="megamenu-item">
                <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item2: !item2,item1:megamenu-item,item3:megamenu-item)">open dropdown</a>
                <div class="dropdpwn-links">
                <div>item1</div>
                <div>item2</div>
                <div>item3</div>
                <div>item4</div>
                </div>
                </li>
                <li [class]="item3 ? 'show' : 'megamenu-item'" class="megamenu-item">
                <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item3: !item3,item2:megamenu-item,item1:megamenu-item)">open dropdown</a>
                <div class="dropdpwn-links">
                <div>item1</div>
                <div>item2</div>
                <div>item3</div>
                <div>item4</div>
                </div>
                </li>
                </ul>
                </body>
                </html>





                <!doctype html>
                <html ⚡>
                <head>
                <meta charset="utf-8">
                <link rel="canonical" href="final.html">
                <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
                <style amp-boilerplate>body-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both@-webkit-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-moz-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-ms-keyframes -amp-startfromvisibility:hiddentovisibility:visible@-o-keyframes -amp-startfromvisibility:hiddentovisibility:visible@keyframes -amp-startfromvisibility:hiddentovisibility:visible</style><noscript><style amp-boilerplate>body-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none</style></noscript>
                <script async src="https://cdn.ampproject.org/v0.js"></script>
                <script async custom-element="amp-selector" src="https://cdn.ampproject.org/v0/amp-selector-0.1.js"></script>
                <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
                <style amp-custom>
                .megamenu-item .dropdpwn-links
                display:none;


                .megamenu-item.show .dropdpwn-links
                display:block;

                </style>
                </head>
                <body>
                <ul>
                <li [class]="item1 ? 'show' : 'megamenu-item'" class="megamenu-item">
                <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item1: !item1,item2:megamenu-item,item3:megamenu-item)">open dropdown</a>
                <div class="dropdpwn-links">
                <div>item1</div>
                <div>item2</div>
                <div>item3</div>
                <div>item4</div>
                </div>
                </li>
                <li [class]="item2 ? 'show' : 'megamenu-item'" class="megamenu-item">
                <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item2: !item2,item1:megamenu-item,item3:megamenu-item)">open dropdown</a>
                <div class="dropdpwn-links">
                <div>item1</div>
                <div>item2</div>
                <div>item3</div>
                <div>item4</div>
                </div>
                </li>
                <li [class]="item3 ? 'show' : 'megamenu-item'" class="megamenu-item">
                <a href="#" tabindex="0" role="button" on="tap:AMP.setState(item3: !item3,item2:megamenu-item,item1:megamenu-item)">open dropdown</a>
                <div class="dropdpwn-links">
                <div>item1</div>
                <div>item2</div>
                <div>item3</div>
                <div>item4</div>
                </div>
                </li>
                </ul>
                </body>
                </html>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 14 '18 at 12:00









                Bachcha SinghBachcha Singh

                2,19521025




                2,19521025



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279944%2fimplement-toggle-display-between-items-in-amp%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    Node.js Script on GitHub Pages or Amazon S3

                    Museum of Modern and Contemporary Art of Trento and Rovereto