JQuery 可滚动文本

2022-01-11 00:00:00 jquery jquery-plugins html

我正在寻找一个将文本绑定到可滚动框内的 jquery 插件.大多数滚动插件都在转换浏览器滚动条,但我想保持原样并且可用.这只是为了在小空间中包含大量文本.

I'm searching for a jquery plugin that will bound text inside a scrollable box. Most of the scroll plugins are converting the browser scroll bar but I want to keep that as it is and usuable. This is just to contain a large amount of text in a small space.

就像这样 页面 在最底部它们包含一个一个小的可滚动框中的大量文本.我试图实现这个插件,但我对 JQuery 有点陌生,所以微不足道的指令不足以让我站起来.如果我可以使用这个插件来做我想做的事,这段代码对吗?:

It's like this page where at the very bottom they are containing a large amount of text in a small scrollable box. I tried to implement this plugin but I'm kinda new to JQuery so the meager instructions weren't enough for me to get off my feet. If I can use this plugin to do what I want, is this code right?:

<script>
$(document).ready(function(e) {
    $(".Information").uscrollbar();
});
</script>

<div id="Hotel" class="Information">
        <p>blah</p>
        <p>blah</p>
        <p>blah</p>
        <p>blah</p>
        <p>blah</p>
        <p>blah</p>
        <p>blah</p>
        <p>blah</p>
        <p>blah</p>
        <p>blah</p>
        <p>blah</p>
        <p>blah</p>
    </div>

推荐答案

你真的不需要 jQuery.只是一些 CSS.

You really don't need jQuery for this. Just some CSS.

.Information{
height:100px;
overflow:auto;
}

如果您确实需要此插件,请确保您正确引用了 jQuery 以及指向插件 js 文件的链接.

If you have a genuine need for this plugin then make sure you're referencing jQuery correctly and the link to the plugin js file.

如果您在浏览器中运行该页面,您是否会在控制台窗口中看到任何内容.任何错误.

If you run the page in your browser do you get anything in the console window. Any errors.

添加了 JSFiddle

还要确保您引用了所需的资产:

Also be sure you're referencing the required assets:

jquery.uscrollbar.js
jquery.uscrollbar.css

相关文章