【问题标题】:JS Accordion closes while clicking links insideJS Accordion 在单击内部链接时关闭
【发布时间】:2018-06-06 15:21:29
【问题描述】:

在单击手风琴下拉菜单中的链接时,我在保持手风琴打开时遇到了一些问题。这是一个职业页面,当我打开单个工作时,我希望用户能够在新选项卡中打开应用程序。有什么想法吗?

https://www.trinovainc.com/careers.html

<div class="accordion">
  <div class="accordion-panel careers" data-id="panel-1">
    <div class="accordion">
      <h4><a class="accordion-title">Application Engineer - Mobile, AL<span class="ion-chevron-down"></span></a></h4>
    </div>
    <div class="accordion-panel-content panel-1">
      <p>TriNova is looking for an energetic and personable candidate who is a self-motivated and well-organized professional to join our team as an Application Engineer.</p>
      <h4>Summary</h4>
      <ul>
        <ul>
          <li>Provides in-depth product and application knowledge for TriNova and customers; specifically providing inside sales support for account managers. Duties to include reviewing of specifications, verifying model codes, quoting, ordering, expediting and communicating with the customer and sales force.</li>
        </ul>
      </ul>
      <h4>PRIME RESPONSIBILITIES</h4>
      <ul>
        <ul>
          <ul>
            <li>Review all types of applications that consist of but not limited to: sizing valves, choosing instruments, sizing gamma, sizing flowmeters and creating electrical &amp; PID drawings for various types of field instrument panels.</li>
            <li>Review specifications and provide model codes for products.</li>
            <li>Perform CAD drawings of best practice installation and wiring</li>
            <li>Communicate with the customer, outside salespeople, manufacturers and the Area Vice President.</li>
            <li>Understand commercial issues and terms.</li>
            <li>Field visits with account managers for relationship development, training and as required to optimize the order process and achieve customer satisfaction</li>
            <li>Improve product and technical knowledge.</li>
            <li>Troubleshooting of basic device issues.</li>
          </ul>
        </ul>
      </ul>
      <h4>MINIMUM EDUCATION</h4>
      <ul>
        <ul>
          <ul>
            <li>Bachelor&rsquo;s Degree in Engineering.</li>
            <li>Minor in Sales Engineering is a plus</li>
          </ul>
        </ul>
      </ul>
      <h4>TRAVEL</h4>
      <ul>
        <ul>
          <ul>
            <li>Occasional travel required.</li>
          </ul>
        </ul>
      </ul>
      <h4>PREVIOUS JOB EXPERIENCE</h4>
      <h4>Desired:</h4>
      <ul>
        <ul>
          <ul>
            <li>Previous related experience of at least 2 years</li>
          </ul>
        </ul>
      </ul>
      <h4>Required:</h4>
      <ul>
        <ul>
          <li>None</li>
          <ul></ul>
        </ul>
      </ul>
      <a class="button orange apply" href="https://www.trinovainc.com/job-application.html" target="_blank">Apply Now</a>
    </div>
  </div>
</div>

【问题讨论】:

    标签: javascript html magento


    【解决方案1】:

    使用event.stopPropagation():

    在 Javascript 中,您有事件冒泡,这意味着每当为元素触发事件时。该事件会冒泡到所有父元素。这意味着如果您有一个用于关闭手风琴的 onlick,并且您单击其中的按钮(或其他任何东西),它将关闭。您可以使用event.stopPropagation() 来防止这种情况。这将阻止事件传播 DOM 结构。

    例子:

    function prop(e){
      console.log(e.currentTarget);
    }
    
    function notProp(e){
      console.log(e.currentTarget);
      e.stopPropagation();
    }
    <div id="propagated" onclick="alert('Bubbled')"><button onclick="prop(event)">Click</button></div>
    
    <div id="notpropagated" onclick="alert('OH NO')"><button onclick="notProp(event)">Click</button></div>

    【讨论】:

    • @sotechworks 你知道了吗?如果您需要进一步说明,请告诉我。
    • 其实我还没弄明白。
    • 我在打开手风琴内的应用按钮时遇到了一些问题。
    • '有一些问题'...它们与问题中描述的问题相同吗?
    • @sotechworks 尝试将其添加到 a 标签(“应用按钮”):onclick="event.stopPropagation()"
    猜你喜欢
    • 2016-03-14
    • 1970-01-01
    • 1970-01-01
    • 2017-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-28
    • 2014-04-11
    相关资源
    最近更新 更多