Questions tagged «jquery»

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

15
如何根据内容动态调整Twitter Bootstrap模式的大小
我的数据库内容包含不同类型的数据,例如Youtube视频,Vimeo视频,文本,Imgur图片等。它们的高度和宽度都不同。我在搜索Internet时发现的所有内容都将大小更改为仅一个参数。它必须与弹出窗口中的内容相同。 这是我的HTML代码。我还使用Ajax来调用内容。 <div id="modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3 id="ModalLabel"></h3> </div> <div class="modal-body"> </div> </div>


2
Uncaught TypeError:无法使用'in'运算符在其中搜索'length'
未捕获的TypeError:无法使用“ in”运算符在“ 这是我尝试$.each对此JSON对象执行操作时收到的错误: {"type":"Anuncio","textos":["Probando esto","$ 20150515"],"submit":"codParameters?___DDSESSIONID\u003d14EA4721A904D6DD71591156996E29F7%3A%2FMobilTest"} 我也尝试对stringify执行相同的操作,但收到相同的错误: {\"type\":\"Anuncio\",\"textos\":[\"Probando esto\",\"$ 20150515\"],\"submit\":\"codParameters?___DDSESSIONID\\u003d06CBEC9D1A53616EFF703A8C71FBC2B4%3A%2FMobilTest\"}" 如果我___DDSESSIONID\\u003d06CBEC9D1A53616EFF703A8C71FBC2B4%3A%2FMobilTest从对象中删除参数,则$ .each可以正常工作。 为什么会这样呢?



12
Ajax处理中的“无效的JSON原语”
我在jQuery的ajax调用中遇到错误。 这是我的jQuery函数: function DeleteItem(RecordId, UId, XmlName, ItemType, UserProfileId) { var obj = { RecordId: RecordId, UserId: UId, UserProfileId: UserProfileId, ItemType: ItemType, FileName: XmlName }; var json = Sys.Serialization.JavaScriptSerializer.serialize(obj); $.ajax({ type: "POST", url: "EditUserProfile.aspx/DeleteRecord", data: json, contentType: "application/json; charset=utf-8", dataType: "json", async: true, cache: false, success: function(msg) { if (msg.d != …
101 c#  jquery  webmethod 

5
Javascript函数和默认参数,不适用于IE和Chrome
我创建了这样的函数: function saveItem(andClose = false) { } 在Firefox中工作正常 在IE中,它会在控制台上显示此错误: Expected ')' 在Chrome中,它会在控制台中显示此错误: Uncaught SyntaxError: Unexpected token = 两种浏览器都将错误源标记为函数创建行。
101 javascript  jquery 

13
JavaScript中的正数到负数?
基本上是abs的反向。如果我有: if ($this.find('.pdxslide-activeSlide').index() < slideNum - 1) { slideNum = -slideNum } console.log(slideNum) 无论哪个控制台始终返回正数。我该如何解决? 如果我做: if ($this.find('.pdxslide-activeSlide').index() < slideNum - 1) { _selector.animate({ left: (-slideNum * sizes.images.width) + 'px' }, 750, 'InOutPDX') } else { _selector.animate({ left: (slideNum * sizes.images.width) + 'px' }, 750, 'InOutPDX') } 它可以正常工作,但不是“ DRY”,只是愚蠢地将整个代码块用于-。
101 javascript  jquery  math 

9
data.map不是函数
我为无法解决的错误而b之以鼻。我有以下内容; JSON格式 {"products": [ { "product_id" : "123", "product_data" : { "image_id" : "1234", "text" : "foo", "link" : "bar", "image_url" : "baz" } },{ "product_id" : "456", "product_data" : { "image_id" : "1234", "text" : "foo", "link" : "bar", "image_url" : "baz" } } ]} 和下面的jQuery function getData(data) { …
101 jquery  json 

18
Bootstrap下拉菜单不起作用
我无法正常使用下拉菜单。我可以使导航栏完美显示,但是当我单击“ Dropdown”(二者之一)时,它不会显示下拉菜单。我曾尝试查看有关此问题的其他文章,但是没有什么能解决每个人的问题。我直接从bootstrap网站复制了源代码,但似乎无法在我的机器上使用它。有人有主意吗?我盯着它看了一个小时,似乎无法弄清楚问题出在哪里。 <head> <script src="resource/js/jquery-1.11.0.js"></script> <script src="resources/js/bootstrap.js"></script> <script type="text/javascript"> $(document).ready(function() { $('dropdown-toggle').dropdown() }); </script> </head> <body> <nav class="navbar navbar-default" role="navigation"> <div class="container-fluid"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data- target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> …

13
使用jQuery将一个标签替换为另一个标签
目标: 使用jQuery,我试图替换所有出现的情况: <code> ... </code> 与: <pre> ... </pre> 我的解决方案: 我了解到以下内容: $('code').replaceWith( "<pre>" + $('code').html() + "</pre>" ); 我的解决方案的问题: 但是问题在于它用第一个 “ code”标签之间的内容替换了(第二,第三,第四等)“ code”标签之间的所有内容。 例如 <code> A </code> <code> B </code> <code> C </code> 变成 <pre> A </pre> <pre> A </pre> <pre> A </pre> 我认为我需要使用“ this”和某种功能,但恐怕我还在学习,并且不太了解如何将解决方案组合在一起。


5
在jquery中使用AJAX Post的正确方法可以从强类型MVC3视图传递模型
我是Web程序员的新手,所以如果我的某些“行话”不正确,请原谅我。我有一个使用MVC3框架的ASP.NET项目。 我正在管理员视图上,管理员将在其中修改设备列表。功能之一是“更新”按钮,在将帖子发送到MVC控制器后,我想使用jquery动态编辑网页上的条目。 我认为这种方法在单个管理员设置中是“安全的”,在这种情况下,网页与数据库不同步的担忧最小。 我创建了一个强类型化的视图,希望使用AJAX发布将模型数据传递给MVC控件。 在下面的文章中,我发现了与我正在做的事情类似的事情: 导致空参数的JQuery Ajax和ASP.NET MVC3 我将使用以上文章中的代码示例。 模型: public class AddressInfo { public string Address1 { get; set; } public string Address2 { get; set; } public string City { get; set; } public string State { get; set; } public string ZipCode { get; set; } public …

14
JQuery的黄色淡入淡出效果
我想实现类似于37Signals的Yellow Fade效果。 我正在使用Jquery 1.3.2 代码 (function($) { $.fn.yellowFade = function() { return (this.css({backgroundColor: "#ffffcc"}).animate( { backgroundColor: "#ffffff" }, 1500)); } })(jQuery); 而下一个呼叫显示为黄色,则会淡化带有框号的DOM元素。 $("#box").yellowFade(); 但这只会使它变黄。15000毫秒后没有白色背景。 知道为什么它不起作用吗? 解 您可以使用: $("#box").effect("highlight", {}, 1500); 但是您需要包括: effects.core.js effects.highlight.js
100 jquery 

4
Fancybox不适用于jQuery v1.9.0 [f.browser未定义/无法读取属性'msie']
Fancybox打破了新的jQuery v1.9.0。 它同时影响Fancybox v1.3.4和更低版本以及-v2.1.3和更低版本。 显示的错误是: v1.3.4: Timestamp: 15/01/2013 10:03:28 AM Error: TypeError: b.browser is undefined Source File: ...fancybox/jquery.fancybox-1.3.4.pack.js Line: 18 ...其他错误 Uncaught TypeError: Cannot read property 'msie' of undefined jquery.fancybox-1.3.4.pack.js:18 Uncaught TypeError: Object [object Object] has no method 'fancybox' 在v2.1.3中: Timestamp: 15/01/2013 10:09:58 AM Error: TypeError: $.browser is undefined Source …

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.