jquery - 在 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>
解决方案
您可以仅定位h2
s 的直接子级#faqs
,从而排除 , 的子级aside
的s #faqs > h2
:
(我用背景颜色替换了.plus
and.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>
推荐阅读
- spring-boot - 无法在 Spring Boot 应用程序中使用执行器
- monaco-editor - Monaco Editor registerCompletionItemProvider 移除默认的局部变量完成
- python - 是否可以在 python 中更改 PixelAccess 的大小?
- android - txt文件中的可点击单词
- javascript - 我正在尝试使用此代码验证我的购物清单,“...”传播但得到“牛奶”的返回值,并且只是第一个值
- haskell - 定义数据类型时无法匹配预期类型
- c# - 如何使用 C#/Command 调用板载声音
- logging - Hybris 默认在哪里存储 Cronjob 日志?
- vb.net - 从 vb.net 中的数据网格视图更新数据库
- c# - System.Xml.XmlException:“=”字符,十六进制值 0x3D,不能包含在名称中