Questions tagged «jquery»

jQuery是一个JavaScript库,请考虑添加JavaScript标记。jQuery是一种流行的跨浏览器JavaScript库,它通过最小化浏览器之间的差异来促进文档对象模型(DOM)遍历,事件处理,动画和AJAX交互。标记为jQuery的问题应与jQuery相关,因此问题代码应使用jQuery,并且问题中至少需要与jQuery使用相关的元素。

13
Laravel CSRF令牌与Ajax POST请求不匹配
我正在尝试通过ajax从数据库中删除数据。 HTML: @foreach($a as $lis) //some code <a href="#" class="delteadd" id="{{$lis['id']}}">Delete</a> //click action perform on this link @endforeach 我的ajax代码: $('body').on('click', '.delteadd', function (e) { e.preventDefault(); //alert('am i here'); if (confirm('Are you sure you want to Delete Ad ?')) { var id = $(this).attr('id'); $.ajax({ method: "POST", url: "{{url()}}/delteadd", }).done(function( msg …
112 php  jquery  ajax  laravel 

13
使用jQuery检测Safari
尽管两者都是基于Webkit的浏览器,但Safari会在URL中用引号将引号引起来,而Chrome则不会。 因此,我需要在JS中区分这两者。 jQuery的浏览器检测文档将“ safari”标记为已弃用。 有没有更好的方法,或者我现在只是坚持不赞成使用的值?

9
如何检查引导模态是否打开,所以我可以使用jQuery validate
我只需要在模式打开的情况下进行验证,因为如果我打开它,然后将其关闭,然后我按打开模式的按钮就行不通了,因为它正在进行jQuery验证,但是没有展示是因为该模式被解雇了。 所以如果模态是开放的,我想广告一个jQuery,所以我可以验证,这可能吗? <script> $(document).ready(function(){ var validator =$('#form1').validate( { ignore: "", rules: { usu_login: { required: true }, usu_password: { required: true }, usu_email: { required: true }, usu_nombre1: { required: true }, usu_apellido1: { required: true }, usu_fecha_nac: { required: true }, usu_cedula: { required: true }, usu_telefono1: { required: …


14
如何检测在线/离线事件跨浏览器?
我正在尝试使用HTML5联机和脱机事件来准确检测浏览器何时脱机。 这是我的代码: <script> // FIREFOX $(window).bind("online", applicationBackOnline); $(window).bind("offline", applicationOffline); //IE window.onload = function() { document.body.ononline = IeConnectionEvent; document.body.onoffline = IeConnectionEvent; } </script> 当我在Firefox或IE上单击“脱机工作”时,它工作正常,但是当我拔掉电线时,它是随机工作的。 检测此更改的最佳方法是什么?我想避免重复超时的ajax调用。

5
$(document).ready是否必要?
我在stackoverflow中看到了这个问题,但根本感觉不到答案。 有$(document).ready必要吗? 我在页面底部链接了我的所有JavaScript,因此从理论上讲,它们在文档准备就绪后都可以运行。

6
在不同输入中按Enter键时会触发Button Click事件(无格式)
当在“金额”输入中按“ Enter”键时,就会触发此逻辑,但我不认为应该这样做(Chrome中没有)。我该如何防止这种情况发生,如果不能在IE中阻止这种情况,请对其进行处理,以使click事件中的逻辑不会触发。 <html> <body> <div id="page"> <div id="financed_amount"> <h1>Financed Amount:</h1> <input type="text" id="amount" value="" /> </div> <h1>Finance Options</h1> <div> <a id="shareLink" rel="leanModal" name="email" href="#email"></a> <button id="btnShare" class="share">Share this report</button> </div> </div> </body> </html> 脚本 $("#btnShare").click(function (e) { // This logic is firing when pressing "Enter" in the "Amount" input }); …



4
jQuery向左滑动并显示
我延长了jQuery所谓的效果slideRightShow(),并slideLeftHide()与一对夫妇功能的工作类似slideUp(),并slideDown()如下图所示。但是,我也想实现slideLeftShow()和slideRightHide()。 我知道有很多提供此类功能的库(我想避免添加另一套大javascript文件),但是任何人都可以提供一个简单示例来说明如何实现slideLeftShow()或slideRightHide()吗? jQuery.fn.extend({ slideRightShow: function() { return this.each(function() { jQuery(this).animate({width: 'show'}); }); }, slideLeftHide: function() { return this.each(function() { jQuery(this).animate({width: 'hide'}); }); }, slideRightHide: function() { return this.each(function() { ??? }); }, slideLeftShow: function() { return this.each(function() { ??? }); } }); 上面的slideRightShow功能从左侧开始显示图像,然后向右侧进行。 我正在寻找某种方法来做同样的事情,但要从右侧开始,然后向左侧进行。谢谢! 编辑 jQuery Interface有我需要的东西(我基本上需要它们的“向右滑动”和“向左滑动”功能),但是我无法使用它来与jQuery 1.3配合使用:http : //interface.eyecon.ro/demos …
111 jquery  effects 

7
使用Webpack将jQuery公开到真实的Window对象
我想将jQuery对象公开给可在浏览器的开发人员控制台内部访问的全局窗口对象。现在在我的webpack配置中,我有以下几行: plugins: [ new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }) ] 这些行将jQuery定义添加到我的webpack模块中的每个文件中。但是,当我构建项目并尝试像这样在开发人员控制台中访问jQuery时: window.$; window.jQuery; 它说这些属性是不确定的... 有没有办法解决这个问题?


1
jQuery-如果元素具有类,请执行此操作
我需要一个jQuery脚本,该脚本将查看是否有任何元素具有特定的类并执行诸如更改位置之类的操作。 这是这种方式,但是我认为这不会起作用。 $("a.contact").toggle(function() { $("#contact").animate({ right: '0' }, 2000); if ($("#about").hasClass("opened")) { $("#about").animate({ right: -700 + "px" }, 2000); } }, function() { $("#contact").animate({ right: -700 + "px" }, 2000); });
111 javascript  jquery 

6
如何在提交前添加其他字段到表单?
有没有一种方法可以使用javascript和JQuery添加一些其他字段,以使用POST从HTTP表单发送这些字段? 我的意思是: <form action="somewhere" method="POST" id="form"> <input type="submit" name="submit" value="Send" /> </form> <script type="text/javascript"> $("#form").submit( function(eventObj) { // I want to add a field "field" with value "value" here // to the POST data return true; }); </script>
111 jquery  html  forms  post  field 

5
IE中出现jQuery ajax调用时出现“无传输”错误
我需要使用foursquare API搜索场所。当然,它是跨域的。 它在Firefox中没有任何问题,但是在Internet Explorer中(我已经测试过7、8、9)。 我的JavaScript代码如下所示: searchVenues: function(searchQuery) { $.ajax({ url: 'https://api.foursquare.com/v2/venues/search', data: { sw: bound_south_west, ne: bound_north_east, query: searchQuery.query, oauth_token: FSQ_OAUTH_TOKEN, limit: 25, intent: 'browse', v: 20120206 }, cache: false, dataType: 'json', success: function(data) { displayResults(data, searchQuery.query); }, error: function(xhr, status, errorThrown) { console.log(errorThrown+'\n'+status+'\n'+xhr.statusText); } }); } 在Firefox中,它可以完美显示接收到的数据。在Internet Explorer中,它登录控制台: No …

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.