jquery仅返回筛选结果中的文本
我的html过滤给了我
$.get(myURL, function(data) { $(data).find("td.Chats").filter(':gt(5)').appendTo('#regions'); }, 'html')
结果:
Item 1 Item 2 Item 3
我如何才能获得带有文本的元素? 还是每隔5?
你可以使用.filter()
方法:
$(data).find("td.Chats").filter(function(){ return this.innerHTML !== ''; });
或.not()
方法:
$(data).find("td.Chats").not(':empty');
如果要排除第一个元素:
$(data).find("td.Chats").not(':empty').not(':first');