Tag: javascript

将div转换为图像的最佳方法? 使用php,javascript或jquery

我有一个div包含这样的图像: 我想导出这个div作为图像因为我创建像设计生成器的东西。 到目前为止,我所做的是使用window.open将新创建的设计放在新窗口上,就像预览设计一样。 所以我的问题是: 我可以转换此div并将其直接保存为图像吗? 我正在考虑将其导出到canvas,以便我可以将其保存为图像。 如何将其导出到canvas? 还有其他方法吗?

如何制作带箭头的猫头鹰旋转木马而不是下一个

昨天我向一位顾客推出了一个网站。 我总是使用猫头鹰旋转木马,因为它的响应。 客户如何讨厌以前的,接下来的话,并希望将它们改为箭头。 所以我更新了我的脚本。 js文件。 这很容易做到,我想分享它。 $(document).ready(function(){ $(‘.owl-carousel’).owlCarousel({ nav:true, responsive:{ … }) $( “.owl-prev”).html(”); $( “.owl-next”).html(”); }); 在那里,你有它。 您可以随时添加更多样式。 (我第一次使用答案你自己的问题希望这是正确的地方/方式)

只允许英文字符和数字输入文字

现场演示: http : //jsfiddle.net/thisizmonster/DveuB/ 如何更改此选项,以便输入仅在键入时允许字符AZ,az,0-9,而不使用正则表达式?

提交搜索查询并获取搜索结果而不刷新

我想提交搜索查询表单并获取搜索结果,而无需在同一页面上重定向/重新加载/刷新 。 我的内容是动态的,所以不能使用那些“提交联系表格而不刷新回复成功的页面”。

使用屏幕分辨率的移动重定向

我宣传一家公司,基本上我是一个会员。 我想将移动浏览器重定向到我的联盟网站的移动版本。 我想用屏幕分辨率来做这件事。 基本上,如果屏幕分辨率不是800 x 600,则客人使用手机的可能性很大。 这是一个很好的想法吗? 这是代码: if ( (screen.width < 800) && (screen.height < 600) ) { window.location = 'mobilesite'; } 泰!

jQuery – 通过单个请求提交多个表单,没有Ajax

我有一个包含多种表格的页面。 我正在尝试提交其中一个表单(比如表单A)(不是通过Ajax,因为我需要在处理提交后加载结果页面),但是我需要另一个表单的内容(比如表单B)与TOGETHER一起提交表单A,即表单A + B的内容应作为一个请求一起提交给SAME URL,并且正如我之前所说,不是作为Ajax请求。 提交应该是POST请求。 此外,表单仅包含非文件上载的字段(即输入,选择,textarea字段)。 我在这里看到过诸如此类的建议 在jQuery中发布/提交多个表单 要么 使用单个按钮提交两个表单 但要注意这些与我的情况不符,因为表单是在不同的请求中提交的,和/或它们是通过Ajax提交的。 我想通过(jQuery的)serialize()获取其中一个表单的内容,但是如何将该字符串附加到POST提交的表单中? 或者您可能有其他想法如何实现这一目标? 解: 根据Sheepy和YoTsumi的想法,我写了下面的代码。 我也从以下链接使用Pointy的答案: 将多个表单提交到同一页面 //Arguments: “name”s of forms to submit. //First argument: the form which according to its “action” all other forms will be submitted. //Example: mergeForms(“form1″,”form2″,”form3″,”form4”) function mergeForms() { var forms = []; $.each($.makeArray(arguments), function(index, value) { forms[index] = document.forms[value]; […]

在jQuery中模拟Hover

目前,我有一些jQuery / Javascript代码,当用户将鼠标hover在某些元素上时切换css类’ui-state-hovered’,我想在konacha中编写测试来测试这段代码。 如何在jQuery的帮助下在Javascript中编写这个函数? 如果用户将鼠标hover在元素$(’。someClass li:first’)上,则返回true,类’ui-state-hovered’存在。 否则返回false。 我如何模拟将鼠标hover在该元素上的用户?

页面/浏览器失焦时暂停setInterval

我有一个简单的幻灯片,我在客户的主页上制作,使用setInterval为旋转计时。 为了防止浏览器在页面未对焦(正在查看另一个选项卡或其他程序)时搞砸setInterval,我正在使用: function onBlur() { clearInterval(play); }; function onFocus() { mySlideRotateFunction(); }; if (/*@cc_on!@*/false) { document.onfocusin = onFocus; document.onfocusout = onBlur; } else { window.onfocus = onFocus; window.onblur = onBlur; } mySlideRotateFunction设置setInterval并运行一些jQuery。 虽然这在大多数情况下是有效的,但我发现,有时看起来似乎onBlur还没有运行,当我回到页面时,时间已经“积累”并且旋转变得疯狂。 我无法确定为什么有时会发生这种情况的原因,而不是其他原因。 我的问题 – 我的代码存在问题,当浏览器窗口失焦时,是否有人更好地建议“暂停”setInterval? 谢谢

如何使用Require.js实现TinyMCE?

我目前正在将TinyMCE源作为依赖项传递,然后调用tinyMCE.init({}); 但它没有初始化TinyMCE。 当我在console.log TinyMCE时,它返回一个TinyMCE对象。 代码示例如下: define([ ‘jQuery’, ‘Underscore’, ‘Backbone’, ‘TinyMCE’ ], function($, _, Backbone, tinyMCE) { tinyMCE.init({ mode: “exact”, elements: $(‘textarea’), theme: “advanced”, theme_advanced_toolbar_location: ‘top’, theme_advanced_buttons1: ‘bold,italic,underline,bullist,numlist,link,unlink’, theme_advanced_buttons2: ”, theme_advanced_buttons3: ”, theme_advanced_toolbar_align: ‘left’, plugins: ‘paste,inlinepopups’, width: ‘100%’, height: textarea.attr(‘data-height’), oninit: function () { console.log(‘TargetTD :’); console.log(targetTD); } }); } });

ECONFLICT无法为jquery Foundation找到合适的版本

我正在尝试安装基金会,但它一直让我与Jquery发生冲突 λ bower install foundation bower foundation#x cached https://github.com/zurb/bower-foundation.git#5.5.1 bower foundation#x validate 5.5.1 against https://github.com/zurb/bower-foundation.git#x bower foundation#* cached https://github.com/zurb/bower-foundation.git#5.5.1 bower foundation#* validate 5.5.1 against https://github.com/zurb/bower-foundation.git#* bower jquery#>= 2.1.0 cached https://github.com/jquery/jquery.git#2.1.3 bower jquery#>= 2.1.0 validate 2.1.3 against https://github.com/jquery/jquery.git#>= 2.1.0 bower modernizr#>= 2.7.2 cached https://github.com/Modernizr/Modernizr.git#2.8.3 bower modernizr#>= 2.7.2 validate 2.8.3 against https://github.com/Modernizr/Modernizr.git#>= 2.7.2 bower jquery.cookie#~1.4.0 cached https://github.com/carhartl/jquery-cookie.git#1.4.1 […]