Tag: 前端

jQuery使用下一个/上一个按钮滚动到下一个Div类

我想要的是固定导航,使用NEXT和PREV按钮基本上将页面滚动到下一个具有“section”类的div。 我已经设置了jQuery,实际上是为NEXT和PREV href添加了一个click函数。 然后,此单击函数将使用ScrollTop移动到具有.section类的下一个duv。 这是jQuery: $(‘div.section’).first(); // binds a click event-handler to a elements whose class=’display’ $(‘a.display’).on(‘click’, function(e) { // prevents the default action of the link e.preventDefault(); // assigns the text of the clicked-link to a variable for comparison purposes var t = $(this).text(), that = $(this); console.log(that.next()) // checks if it was the […]

两个ajax同时请求同一事件。 什么应该是典型的行为? 如果请求是同步的,它是如何不同的

在下面的javascript代码中,我同时发送两个Ajax请求。 在使用Firebug进行分析后,我得出了一个不寻常的结论: “哪个(Ajax)响应首先是打印最后” 。 问题2:如果我将Ajax url目标分配给随机字符串(比如“abcd”)[不存在]那么ajax调用的总数将增加到3? $(document).ready(function(e) { $(“form[ajax=true]”).submit(function(e) { e.preventDefault(); var form_data = $(this).serialize(); var form_url = $(this).attr(“action”); var form_method = $(this).attr(“method”).toUpperCase(); $(“#loadingimg”).show(); $.ajax({ url: form_url, type: form_method, data: form_data, cache: false, success: function(returnhtml){ alert (“a”); // $(“#result”).html(returnhtml); // $(“#loadingimg”).hide(); } }); $.ajax({ url: form_url, type: form_method, data: form_data, cache: false, success: function(returnhtml){ // […]

Phantomjs – 获取网页的屏幕截图

我有一个URL(例如http://www.example.com/OtterBox-77-24444-Commuter-Series-Optimus/dp/B00A21KPEI/ref=pd_sim_cps_4 )并想要截取它并在我的预览网页。 意思是,用户点击预览按钮,PhantomJS需要以PNG / JPEG格式预览网页 我也可以使用任何其他开源。