Questions tagged «jquery»

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

11
将数据传递到jQuery UI对话框
我正在开发一个ASP.Net MVC网站,在该网站上,我在一个表中列出了来自数据库查询的一些预订,并带有ActionLink来取消特定行上的预订,BookingId例如: 我的预订 <table cellspacing="3"> <thead> <tr style="font-weight: bold;"> <td>Date</td> <td>Time</td> <td>Seats</td> <td></td> <td></td> </tr> </thead> <tr> <td style="width: 120px;">2008-12-27</td> <td style="width: 120px;">13:00 - 14:00</td> <td style="width: 100px;">2</td> <td style="width: 60px;"><a href="/Booking.aspx/Cancel/15">cancel</a></td> <td style="width: 80px;"><a href="/Booking.aspx/Change/15">change</a></td> </tr> <tr> <td style="width: 120px;">2008-12-27</td> <td style="width: 120px;">15:00 - 16:00</td> <td style="width: 100px;">3</td> <td …


10
如何在Javascript中缓存图像
我和我的朋友们在一个网站上工作,我们希望在其中缓存某些图像,以便将来更快地显示它们。我有两个主要问题: 您如何缓存图像? 图像被缓存后如何使用?(只是为了验证图像是否在页面A上缓存,可以从缓存中调用它以在页面B上使用它,对吗?) 此外,有可能设置时,图像的缓存版本将到期? 如果包括示例和/或进一步描述页面的链接,将不胜感激。 我们可以使用原始Javascript或jQuery版本。

6
如何将此元素传递给javascript onclick函数并将类添加到该clicked元素
我有一个如下的html导航代码 function Data(string) { //1. get some data from server according to month year etc., //2. unactive all the remaining li's and make the current clicked element active by adding "active" class to the element $('.filter').removeClass('active'); $(this).addClass('active'); } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="row" style="padding-left:21px;"> <ul class="nav nav-tabs" style="padding-left:40px;"> <li class="active filter"><a …

11
是否根据弹出窗口相对于窗口边缘的X位置更改Bootstrap弹出窗口的位置?
我到处搜寻了互联网,而我发现此stackoverflow帖子很有见地,是否可以根据屏幕宽度更改Bootstrap弹出窗口的位置?,它仍然没有回答我的问题,可能是由于我在理解位置/偏移时遇到了麻烦。 这就是我想要做的。我希望Twitter Bootstap Popover的位置为RIGHT,除非热点Popover的位置超出视口,然后我希望它的位置为LEFT。我正在制作一个具有热点的iPad Web应用程序,当您按一个热点时,会显示信息,但是当水平滚动锁定时,我不希望它出现在视口之外。 我在想它会变成这样: $('.infopoint').popover({ trigger:'hover', animation: false, placement: wheretoplace }); function wheretoplace(){ var myLeft = $(this).offset.left; if (myLeft<500) return 'left'; return 'right'; } 有什么想法吗?谢谢!

10
如何在JavaScript中将参数传递给匿名函数?
我试图弄清楚如何将参数传递给JavaScript中的匿名函数。 查看此示例代码,我想您会明白我的意思的: <input type="button" value="Click me" id="myButton" /> <script type="text/javascript"> var myButton = document.getElementById("myButton"); var myMessage = "it's working"; myButton.onclick = function(myMessage) { alert(myMessage); }; </script> 单击按钮时,it's working将出现消息:。但是,myMessage匿名函数中的变量为null。 jQuery使用许多匿名函数,传递该参数的最佳方法是什么?

12
使用jQuery获取选定复选框的值
我想遍历复选框组“ locationthemes”,并使用所有选定值构建一个字符串。所以,当复选框2和4被选出的结果将是:“3,8” <input type="checkbox" name="locationthemes" id="checkbox-1" value="2" class="custom" /> <label for="checkbox-1">Castle</label> <input type="checkbox" name="locationthemes" id="checkbox-2" value="3" class="custom" /> <label for="checkbox-2">Barn</label> <input type="checkbox" name="locationthemes" id="checkbox-3" value="5" class="custom" /> <label for="checkbox-3">Restaurant</label> <input type="checkbox" name="locationthemes" id="checkbox-4" value="8" class="custom" /> <label for="checkbox-4">Bar</label> 我在这里检查过:http : //api.jquery.com/checked-selector/,但是没有示例如何通过其名称选择复选框组。 我怎样才能做到这一点?

12
如何检查iframe是否已加载或是否包含内容?
我有一个id =“ myIframe”的iframe,这里是我加载其内容的代码: $('#myIframe').attr("src", "my_url"); 问题是有时加载时间太长,有时加载速度非常快。所以我必须使用“ setTimeout”函数: setTimeout(function(){ if (//something shows iframe is loaded or has content) { //my code } else { $('#myIframe').attr("src",""); //stop loading content } },5000); 我唯一想知道的是如何确定是否已加载iFrame或是否包含内容。使用iframe.contents().find()将不起作用。我不能用iframe.load(function(){})。

8
使用Javascript加载jQuery并使用jQuery
我使用以下方法将jQuery库附加到dom: var script = document.createElement('script'); script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'; script.type = 'text/javascript'; document.getElementsByTagName('head')[0].appendChild(script); 但是,当我运行时: jQuery(document).ready(function(){... 控制台报告错误: Uncaught ReferenceError: jQuery is not defined 如何动态加载jQuery,以及如何将其放入dom中使用它?

6
关闭(不离开)页面时的jQuery beforeunload?
如何显示“您确定要离开页面吗?” 当用户实际上试图关闭页面(单击浏览器窗口或选项卡上的X按钮)时,而不是当用户试图离开页面导航(单击另一个链接)时。 我的客户希望用户尝试关闭页面时显示一条消息“您确定要离开页面吗?您的购物车中仍然有商品。” 不幸的是$(window).bind('beforeunload'),仅当用户关闭页面时才会触发。 jQuery的: function checkCart() { $.ajax({ url : 'index.php?route=module/cart/check', type : 'POST', dataType : 'json', success : function (result) { if (result) { $(window).bind('beforeunload', function(){ return 'leave?'; }); } } }) }



18
检查的东西isEmpty在Javascript?
如何检查Javascript中的变量是否为空?很抱歉这个愚蠢的问题,但是我是Java语言的新手! if(response.photo) is empty { do something else { do something else } response.photo来自JSON,有时可能为空,数据单元为空!我想检查一下是否为空。

8
如何使用jQuery更改视频src?
如何使用jQuery更改HTML5视频标签的src? 我得到了这个HTML: <div id="divVideo"> <video controls> <source src="test1.mp4" type="video/mp4" /> </video> </div> 这不起作用: var videoFile = 'test2.mp4'; $('#divVideo video source').attr('src', videoFile); 如果我使用Firebug进行检查,它会更改src,但实际上不会更改正在播放的视频。 我读到有关.pause()和.load()的信息,但是我不确定如何使用它们。
83 jquery  video  html 


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.