HTML5 Add toggle thumbnail mode and list mode plugin tutorial

Source: Internet
Author: User

First, the HTML structure
<main id= ' container ' >
<span>View:</span>
<button class= ' view-list ' >List</button>
<button class= ' View-grid ' >Grid</button>
<ol class= ' grid ' id= ' frame ' >
<li class= ' frame ' >
<div class= ' inset ' >
<div class= ' image ' ></div>
<div class= ' info ' >
<div class= ' title ' >lorem ipsum</div>
<div class= ' description ' ></div>
<div class= ' shares ' >
<div class= ' Icon-lik likes ' ></div>
<div class= ' icon-ask comments ' ></div>
</div>
</div>
</div>
</li>
</ol>
</main>

Second, call the plug-in
<link rel= ' stylesheet ' href= ' http://libs.useso.com/js/jqueryui/1.10.4/css/jquery-ui.min.css ' >
<script src= ' http://libs.useso.com/js/jquery/1.11.0/jquery.min.js ' ></script>
<script src= ' http://libs.useso.com/js/jqueryui/1.10.4/jquery-ui.min.js ' ></script>


$ (' #header button '). On (' click ', function () {
if ($ (this). Hasclass (' view-list ')) {
$ (' #frame '). Removeclass (' grid '). addclass (' list ');
} else if ($ (this). Hasclass (' View-grid ')) {
$ (' #frame '). Removeclass (' list '). addclass (' grid ');
}
});


$ ('. Frame '). each (function () {
var images = [' 1.jpg ', ' 2.jpg ', ' 3.jpg ', ' 4.jpg ', ' 5.jpg ', ' 6.jpg '];
$ (this). Find ('. Image ')
. css ({' background-image ': ' url (' +images[math.floor (Math.random () *images.length) ']+ ') '});
var like = 100,
Likes = Math.floor (Math.random () * like) + 1;
$ (this). Find ('. Likes '). Text (likes);
var comment = 50,
Comments = Math.floor (Math.random () * comment) + 1;
$ (this). Find ('. Comments '). Text (comments);
});

Keymob Mobile Advertising platform is the most advanced mobile advertising platform for advertisers to provide accurate and efficient app marketing services, for developers to provide the SDK advertising cooperation, to achieve the advertising owners and developers win!

HTML5 Add toggle thumbnail mode and list mode plugin tutorial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.