首页 > 解决方案 > 在 textArea 中使用完美的滚动条插件

问题描述

您好朋友,我想在 Angular 的 textarea 中使用完美的滚动条,请帮助我。

<div>
                <textarea class="form-control textarea-box comment-box" maxlength="1000" [formControl]="form.controls['comment']" ></textarea>
                </div>
                <span class="maxTxt"><strong>Note:</strong> {{showMessage}}</span>

标签: jquery

解决方案


您可以仅定位h2s 的直接子级#faqs,从而排除 , 的子级aside的s #faqs > h2

(我用背景颜色替换了.plusand.minus样式,因此更改将在 SO 上可见)

$("#faqs > h2").addClass('plus');
$("div").addClass('close');
$("#faqs > h2").click(function() {
  $(this).toggleClass('minus');
}); // end click
$("div").click(function() {
  $(this).toggleClass('open');
}); // end click
* {
  margin: 0;
  padding: 0;
}

body {
  font-family: Verdana, Arial, Helvetica, sans-serif;
  font-size: 100%;
  margin: 20px;
  padding: 10px;
}

section {
  padding: 15px 25px;
  width: 650px;
  margin-top: 20px;
  margin-left: 25px;
}

h1 {
  font-size: 150%;
}

h2 {
  font-size: 120%;
  padding: .25em 0 .25em 25px;
  cursor: pointer;
}


/* classes that you will use */

.plus {
  background-color: yellow
}

.minus {
  background-color: red
}

.close {
  display: none;
}

.open {
  display: block;
}

ul {
  padding-left: 45px;
}

li {
  padding-bottom: .25em;
}

p {
  padding-bottom: .25em;
  padding-left: 25px;
}

aside {
  margin-top: 50px;
}

aside h2,
header h2 {
  cursor: auto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section id="faqs">

  <h2>What is jQuery?</h2>
  <div>
    <p>jQuery is a library of the JavaScript functions that you're most likely to need as you develop web sites.
    </p>
  </div>

  <h2>Why is jQuery becoming so popular?</h2>
  <div>
    <p>Three reasons:</p>
    <ul>
      <li>It's free.</li>
      <li>It lets you get more done in less time.</li>
      <li>All of its functions are cross-browser compatible.</li>
    </ul>
  </div>

  <h2>Which is harder to learn: jQuery or JavaScript?</h2>
  <div>
    <p>For most functions, jQuery is significantly easier to learn and use than JavaScript. But remember that jQuery is JavaScript.
    </p>
  </div>

  <aside>
    <h2>Resources:</h2>
    <div>
      <p>jQuery Website - <a href="http://jquery.com" target="_blank">http://jquery.com</a>
      </p>
    </div>
  </aside>
</section>

</body>

</html>


推荐阅读