jQuery从字符串数据中选择

时间:2014-07-17 22:30:25

标签: javascript jquery html css

我很难让这个工作起来。

我的服务器返回一个显示很棒的HTML字符串,它的格式很好。当它从服务器返回时,我这样做:

var elements = $(data);
var strats = elements.find('.myclass');

该字符串包含div个对象,其类如:

myclass item-container another-class

元素数组如下所示:

0: div.myclass.item-container.another-class
1: text
2: div.myclass.item-container.another-class
3: text
4: div.myclass.item-container.another-class
5: text
6: div.myclass.item-container.another-class
7: text
8: div.myclass.item-container.another-class
length: 9
__proto__: Object[0]

但是当我尝试只选择div对象时,数组是空的:

context: undefined
length: 0
prevObject: jQuery.fn.jQuery.init[9]
selector: ".myclass"
__proto__: Object[0]

我尝试了各种各样的选择器,我无法弄明白。我的印象是只使用一个类名的选择器应该可以正常工作。如何获得课程divs的{​​{1}}?

0 个答案:

没有答案