javascript - 手动编辑 "Thumbnail grid with expanding preview"的html/更改.js?

标签 javascript jquery html css

我刚刚将本教程与带扩展预览的缩略图网格一起使用:http://tympanus.net/codrops/2013/03/19/thumbnail-grid-with-expanding-preview/

这适用于扩展预览内容的 javascript generate html 代码。所以我无法手动编辑框的 html,我只能填写标题、描述、图像和链接。

有没有一种简单的方法来更改 .js 文件,我总是必须手动编辑框的 html? 例如,在 html 文件中它会是这样的:

<li>
     <a href="#">
          <img src="img/thumbnail1.png" alt="img01"/>
     </a>
     <div>
          Content
     </div>
 </li>

在这个 div 中是框的内容,在点击时出现。

感谢您的帮助!

菲利普

最佳答案

是的,您肯定可以通过轻松更改负责呈现详细信息页面的函数来做到这一点。

Preview.prototype = {
    create : function() {
        // create Preview structure:
        this.$title = $( '<h3></h3>' );
        this.$description = $( '<p></p>' );
        this.$href = $( '<a href="#">Visit website</a>' );
        this.$details = $( '<div class="og-details"></div>' ).append( this.$title, this.$description, this.$href );
        this.$myDiv = $( '<div class="my-div"></div>' ).append( "My Injected DIVVVVVVVVVVVVVVVVVVVVVVVVVVV" );
        this.$loading = $( '<div class="og-loading"></div>' );
        this.$fullimage = $( '<div class="og-fullimg"></div>' ).append( this.$loading );
        this.$closePreview = $( '<span class="og-close"></span>' );
        this.$previewInner = $( '<div class="og-expander-inner"></div>' ).append( this.$closePreview, this.$fullimage, this.$myDiv,this.$details);
        this.$previewEl = $( '<div class="og-expander"></div>' ).append( this.$previewInner );
        // append preview element to the item
        this.$item.append( this.getEl() );
        // set the transitions for the preview and the item
        if( support ) {
            this.setTransition();
        }
    },

查看我是如何注入(inject)新的 div 的,它在详细信息页面上可见,如下所示。 enter image description here

关于javascript - 手动编辑 "Thumbnail grid with expanding preview"的html/更改.js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34430864/

相关文章:

javascript - 如何在不使用 Flash 的情况下实现图书预览(2 页展开)?

.net - jQuery Ajax - 针对 ASP.NET MVC 运行多个请求

javascript - 如何在 AngularJS 的范围之间附加输入框值

javascript - IOS HTML 禁用双击缩放

javascript - jQuery dataTables - 基于原始行数据的自定义过滤

javascript - 在 JavaScript 中检查 bool

javascript - 如何检查其他输入给定的输入值?

jquery - iOS Phonegap 应用程序使用 XMLHTTPRequest 发布到安全的 Web 服务调用返回状态为 0

PHP ajax成功: function (msg) - get msg

jquery - textarea 填充 jsfiddle 中的表格单元格但不在实际应用程序中