Tag: jquery selectors

在嵌套的json对象中查找和更新,而不更改不同子路径中的相同键对值

这是对我之前的问题的更新在嵌套的json对象中查找和更新 样本数据 TestObj = { “Categories”: [{ “Products”: [{ “id”: “a01”, “name”: “Pine”, “description”: “Short description of pine.” }, { “id”: “a02”, “name”: “Pine”, “description”: “Short description of pine.” }, { “id”: “a03”, “name”: “Poplar”, “description”: “Short description of poplar.” }], “id”: “A”, “title”: “Cheap”, “description”: “Short description of category A.” }, { “Product”: [{ […]

将表格单元格添加到现有表格行jQuery

我正在尝试使用jQuery向表添加值 – 遗憾的是,我不知道如何让jQuery将表单元格添加到现有行。 例如: $(“” + key + “”).click(function(e) { e.preventDefault(); testset(key); }).appendTo(‘#table1’); 这将使用id table1将单元格添加到表的末尾。 使用jQuery将单元格添加到现有表行( )的最佳方法是什么? 快速谷歌没有透露任何东西。 问候, 系统错误

使用jQuery获取所有DOM元素的最佳方法

使用jQuery在页面上获取所有DOM元素的最佳方法是什么? 谢谢, DLiKS 编辑:这适用于使用grayscale.js灰色整个页面的脚本 – http://james.padolsey.com/demos/grayscale/ 。 jQuery,因为我可以! :P

jQuery .not选择器是否与.delegate一起使用?

我正在尝试对id #filter所有元素进行Ajax调用,这些元素没有类.noAjax ,不知怎的,我无法让它工作。 有人可以看看我的语法吗? $(“#filter”).not($(“a.noAjax”)).delegate(“ul#portfolio-list li a”, “click”, function() { if ($.browser.msie) { location.hash = “#/” + this.pathname; } else { location.hash = this.pathname; } return false; }); 当我尝试使用a或a.ajax (我当然在尝试之前添加)作为.delegate的选择器时, .delegate没有任何作用。 使用jjery上面的ajax工作,但它尝试加载内容,即使我点击链接与a.noAjax

的jQuery选择器,它不包含?

如何使用jQuery选择不包含任何元素的所有 元素?

jQuery – 如何动态地将列表项添加到无序列表?

看起来像一个简单的事情(尽管我仍在学习jQuery的细节)。 这是我的HTML: There were errors with your registration: 这是我的(尝试过的)jQuery: // Check Required Fields. $(‘#fbsignup input.required’).each(function () { if ($(this).val().trim() == ”) { $(this).next(’em’).html(‘*’).show(); $(‘#fbsignup .message ul’).add(‘li’).html(‘Fields marked with * are required.’); } }); 这就是它对DOM做的事情: There were errors with your registration: Fields marked with * are required. 它将文本添加到内部html。 我希望它添加一个 元素与我设置的内部html – 我认为这是链接如何工作? 这是我想要最终得到的HTML: There were errors […]

如何将jQuery元素选择应用于字符串变量

我有一些html被提取到一个字符串var,并希望然后在该字符串上使用jQuery元素选择。 这可能吗? 例如: HTML: This is a message. Click here jQuery的: $(‘div.message’).each(function(i, item) { myHtml = $(this).html(); //select tag attributes here )}; 所以在这个例子中,我想从myHtml的标签中提取id和href 。 谢谢

以前的兄弟选择器为jQuery

如果我有一个简单的HTML列表 Item 1 Item 2 Item 3 Item 4 Item 5 在 #some-id 之后很容易选择每个列表项: $(“#some-id ~ li”) 但如何在 #some-id 之前选择项目?

E> F和E + F选择器之间的区别?

我在jQuery中读到: E>F匹配标记名为F所有元素,它们是E直接子元素。 E+F匹配标签名称为F所有元素,其前面紧跟着标签名称E的兄弟。 两者有什么区别? 能提供一个明确而具体的例子吗?

jQuery获得与类最接近的div

我希望用类showchars向最近的div显示数字字符。 我试着这样做: $(‘#maina’).focus(function() { $(this).closest(“div.showchars”).find(“.countchars”).html(“KKK”); $(“#error-1”).html(“”); $(this).closest(“.showchars”).html(“hmm”); }); 有了这个html: Main Alliase/Current Alliase: o ? 当我专注于输入框时,它会重置错误类的内容。 但是不会将文本更改为: hmm中的div。 我哪里出错或者什么是最好的方法来获得最近的div然后实现api: .html(“hmm”) ? 谢谢