Javascript / Jquery – 从字符串中获取数字

字符串看起来像这样 “blabla blabla-5 amount-10 blabla direction-left” 如何在”amount-“之后获取数字,以及在”direction-“之后的文本?

使用twitter bootstrap创建工具提示/弹出窗口后的回调函数?

我想用twitter bootstrap创建工具提示或弹出窗口。 据我所知,没有建立方式来做到这一点。 $(‘#selector’).popover({ placement: ‘bottom’ }); 例如,假设我想将创建的工具提示向上移动5px并从其计算位置离开5px。 有关最佳方法的任何想法吗? 这就是我想做的事情: $(‘#selector’).popover({ placement: ‘bottom’, callback: function(){ alert(‘Awesome’); } });

如何使用jquery / javascript在div中进行选择

有很多代码可以在页面中进行选择,但我想要一个代码在div中进行选择,如果选择在我的div之外,则该函数必须返回空字符串; 有一个jquery插件只适用于textarea而不是div。 (这里) 谢谢

使用带有JqGridforms的bootstrap select2

我试图用jqgridforms实现bootstrap select2,但似乎可以正确。 在jqgrid声明的colmodel我有: {name: ‘staff’, index: ‘staff’, width: 31, formoptions: {elmprefix: ‘(*) ‘}, editable: true, editrules: {required: true}, edittype: ‘select’, editoptions: {value: staff, dataInit: function(element) { $(element).width(260).select2(); } } }, 选项在那里,引导类插入到元素中, <select id="staff" class="select2-offscreen FormElement" role="select" 但我得到的只是选择的空白区域。 见下图。 有人能告诉我为什么会这样,或者告诉我我做错了什么? 谢谢。

使用HTML5文件输入时,在按钮单击时从多个文件上传器中删除文件

如何在这里添加删除按钮就像在这样的文件队列中逐个删除一样 我不使用带有OOB插件的免费文件上传插件的原因是因为我的客户端要求是出于安全目的而且他们需要简单的上传ui而没有任何复杂的插件。 $(function() { var dropZoneId = “drop-zone”; var buttonId = “clickHere”; var mouseOverClass = “mouse-over”; var dropZone = $(“#” + dropZoneId); var ooleft = dropZone.offset().left; var ooright = dropZone.outerWidth() + ooleft; var ootop = dropZone.offset().top; var oobottom = dropZone.outerHeight() + ootop; var inputFile = dropZone.find(“input”); document.getElementById(dropZoneId).addEventListener(“dragover”, function(e) { e.preventDefault(); e.stopPropagation(); dropZone.addClass(mouseOverClass); var x = […]

加载文档上的全屏浏览器窗口

加载页面后如何全屏浏览器窗口? 我在jQuery中使用了类似下面的代码,但它只使用事件点击 ; 但是我想要在负载上工作 jQuery(document).ready(function($) { function fullScreen(){ var docElm = document.documentElement; if (docElm.requestFullscreen) { //alert(“requestFullscreen”); docElm.requestFullscreen(); } else if (docElm.mozRequestFullScreen) { //alert(“mozRequestFullScreen”); docElm.mozRequestFullScreen(); } else if (docElm.webkitRequestFullScreen) { //alert(“webkitRequestFullScreen”); docElm.webkitRequestFullScreen(); } } });

如何将值参数传递给Bootstrap中的modal.show()函数

我有一个页面显示当地咖啡馆的列表。 当用户点击某个咖啡馆时,会显示一个模式对话框,该对话框已经预先填写了“咖啡馆名称”。 该页面包含许多咖啡馆名称,表单应包含他点击的“咖啡馆名称”。 以下是使用链接按钮生成为文本的咖啡馆名称列表 B&Js 10690 N De Anza Blvd Announce CoHo Cafe 459 Lagunita Dr Announce Hot Spot Espresso and Cafe 1631 N Capitol Ave Announce 这是模态forms × Create Announcement Where I am Coding Date 问题是如何将实际值传递给模态forms的“值”属性? 表单“show”事件由“onlick”事件触发 Announce

.delay()和.setTimeout()

根据.delay()上的jQuery文档, .delay()方法最适合延迟排队的jQuery效果。 因为它是有限的 – 例如,它没有提供取消延迟的方法 – .delay()不能替代JavaScript的本机setTimeout函数,这可能更适合某些用例。 请问有人可以扩展吗? 何时使用.delay()更合适,何时使用.setTimeout()更好?

Wikipedia API是否支持CORS或仅支持JSONP?

这个问题与一年前提出的另一个问题有关。 作者询问如何使用JavaScript和Wikipedia API发出cros-origin请求,其中一条评论是: en.wikipedia.org似乎不允许使用CORS 并建议他改用JSONP。 我知道我可以使用JSONP,但如果我可以使用它,我更喜欢CORS。 我试过jsfiddle var url = “https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json”; $.ajax({ url: url, data: ‘query’, dataType: ‘json’, type: ‘POST’, headers: { ‘Api-User-Agent’: ‘Example/1.0’ }, origin: ‘https://jsfiddle.net/’, success: function (data) { console.log(data); //do something with data }}); 并得到以下错误: XMLHttpRequest无法加载https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json 。 对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。 因此,不允许来源“ https://fiddle.jshell.net ”访问。 请求标题: authority:en.wikipedia.org method:OPTIONS path:/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json scheme:https accept:/ accept-encoding:gzip, deflate, sdch accept-language:en-US,en;q=0.8,fr-CA;q=0.6,fr;q=0.4,fr-FR;q=0.2,ru;q=0.2,uk;q=0.2 access-control-request-headers:accept, […]

jQuery文件上传插件:是否可以保留上传文件夹的结构?

我正在尝试这个插件( https://github.com/blueimp/jQuery-File-Upload )并且有趣的文件夹上传。 我想知道插件是否能够保留上传的子文件夹的结构(=上传1个带有3个子文件夹的文件夹,每个包含几个文件)?