使用Booklet Jquery插件,我如何验证最后一页是否显示
Using the Booklet Jquery Plugin, how do I verify the last page was displayed?
我正在使用Booklet插件。如何验证是否显示了最后一页?我试过类似的东西
$(document).ready(function(){
($('.b-page:last').is(':visible'))?alert("da"):alert("nu");
});
但它似乎不起作用。
使用jQuery,您可以检测何时处于最后一页或封底。下面的代码将在加载、调整大小以及更改(blooklet事件)上检测任何一种情况。祝你好运
$(function () {
//Create a function to do stuff...
function dostuff() {
console.log('I am on the last page...');
}
//Create a function that sets a new class, and get the width value of it's element
function mclasswidth() {
//add the new class
$("div[title='End']").parent('div').parent().prev().addClass('dropit');
//Get the width value
var mwidth = $('.dropit').width();
//The big secret...if width is 0, you know you are on the last page / back cover
if (mwidth =='0') {
dostuff();
}
}
//In addition to running booklet code below, you can also use the "change" event to detect if you are on last page (look below)
$("#mybook").booklet({
width: 500,
height: 500,
speed: 250,
covers: true,
closed: true,
startingPage: 4, //(optional)
pageNumbers: false,
pagePadding: 0,
autoCenter: true,
arrows: false,
change: function (event, data) {
//Detect the width value of your new class on page "change", which will do stuff if you are on the last page.
mclasswidth();
//Also on page change, if you already know the index number to the last page, you can do stuff directly
if (data.index == "4") {
dostuff();
}
}
});
//Detect the width value of your new class on "load" and on "resize", which will do stuff if you are on the last page.
$(window).on("resize", function () {
mclasswidth();
}).resize();
});
相关文章:
- 正在验证8个真/假复选框或复选框中的2个
- 表追加而不附加最后一个元素
- 借助asp.net验证或java脚本对多个文本进行验证
- jQuery自定义验证比较多个输入的序列
- 使用html中的外部javascript进行数据验证
- 使用Booklet Jquery插件,我如何验证最后一页是否显示
- jQuery自定义验证只显示最后一个字段的错误
- 在输入时,JavaScript 验证仅在最后一个中起作用
- 仅验证一组单选按钮的最后一个单选按钮
- Javascript 验证也允许在最后第三个位置使用点
- 我想根据他们输入的域验证电子邮件.正在检查最后一个域为.com
- 在Rails助手中使用Javascript调用验证文本字段时,如何返回最后一个有效输入
- 我试图验证一个表单与多个函数,但它只调用最后一个,即使我将它们与逗号结合
- jqGrid客户端验证模式在编辑最后一行时没有正确放置
- Javascript Regex验证字符串长度和最后3个字符是否为数字
- 删除最后一个无效字符,而不是第一个(javascript验证)
- 验证数组的最后一个值是否大于前一个值
- 验证一个月的最后日期
- 如何使用javascript验证日期是否为一个月的最后一天
- 如何暂停表单提交,最后一次验证,在最后和之后释放/触发/继续提交