0

CODE HTML:

<div id="element">
    <div class="col-md-3">
      <div data-role="collapsible">
          <div data-role="trigger">
              <span>Title 1</span>
          </div>
      </div>
      <div data-role="content">Content 1</div>
    </div>
    <div class="col-md-3">
      <div data-role="collapsible">
          <div data-role="trigger">
              <span>Title 2</span>
          </div>
      </div>
      <div data-role="content">Content 2</div>
    </div>
    <div class="col-md-3">
    <div data-role="collapsible">
        <div data-role="trigger">
            <span>Title 3</span>
        </div>
    </div>
    <div data-role="content">Content 3</div>
    </div>
    <div class="col-md-3">
      <div data-role="collapsible">
          <div data-role="trigger">
              <span>Title 4</span>
          </div>
      </div>
      <div data-role="content">Content 4</div>
    </div>
</div>

CODE JS:

require(['jquery','accordion'], function ($) {
        $("#element").accordion({
             "openedState": "active",
            "collapsible": true,
            "active": [0,1,2,3], /** Integrat Dynamic open tab  */
            "multipleCollapsible": true,
        });
    });

I have a function called an accordion and I want it's initialization to be only on the mobile (do not call on the desktop).

How can I do this?

0

Less then 640 width would be mobile you can check this below way

require(['jquery','accordion'], function ($) {
    if ($(window).width() < 640) {
           $("#element").accordion({
             "openedState": "active",
             "collapsible": true,
             "active": [0,1,2,3], /** Integrat Dynamic open tab  */
             "multipleCollapsible": true,
         });
     }
 });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.