1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- $(function () {
- $("img").lazyload();
- const globaldata = {
- active: null,
- maxlength: null,
- };
- // 实现跳转
- let my_nav = $(".my-nav"), top = my_nav.offset().top;
- $(".my-nav").click(function (e) {
- if (e.target.className == "my-nav") return false;
- let active = Array.prototype.slice.call($(this).find("li")).indexOf(e.target);
- if (active == globaldata.active) return false;
- globaldata.active = active;
- $(this).find(".active").removeClass("active");
- $(e.target).addClass("active");
- // 获取跳转锚点到顶部的距离
- let title = $("#title").offset().top;
- let edi_answer = $("#edi-answer").offset().top;
- let interactive = $("#interactive").offset().top;
- let lis = $(this).find("li");
- let i = Array.prototype.slice.call(lis).indexOf($(e.target)[0]);
- // 储存锚点
- let maos = [title, edi_answer, interactive];
- $(window).scrollTop(maos[i]);
- })
- $(window).scroll(
- function () {
- let scrolltop = document.documentElement.scrollTop || document.body.scrollTop;
- if (scrolltop >= top) { my_nav.addClass("fixed"); } else {
- my_nav.removeClass("fixed")
- }
- }
- )
- // 查看更多
- $("[data-click='open']").click(function () {
- let bool = $(this).data("open");
- if (!bool) {
- $(this).data("open", true).children("span").text("收起阅读全部").parent().children("i").removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up").parent().parent().parent().addClass("edi-body-height");
- } else {
- $(this).data("open", false).children("span").text("展开阅读全部").parent().children("i").removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down").parent().parent().parent().removeClass("edi-body-height");
- }
- })
- // 不能实现的事件
- function warm () {
- alert("请在大联考App内登录后操作")
- }
- // $(".edi-open>span[data-click='open']").click(warm)
- $(".edi-user").click(warm)
- $(".choose").click(warm)
- // 默认 时间
- $(".pull-right>span").click(function () {
- $(this).addClass('active').siblings("span").removeClass("active");
- })
- })
|