通过JavaScript过滤DOM元素
我有这样创建的元素:通过JavaScript过滤DOM元素,javascript,jquery,Javascript,Jquery,我有这样创建的元素: function appendCalendarEventToList(className, event) { var eventObject = { title: event.title, id: event.id, type: event.type, color: event.color, description: event.desc
function appendCalendarEventToList(className, event) {
var eventObject = {
title: event.title,
id: event.id,
type: event.type,
color: event.color,
description: event.description,
canReoccur: event.canReoccur,
reoccurVal: event.reoccurVal,
estHours: event.estHours,
project: event.project
};
var div = document.createElement("div");
div.className = 'external-event';
div.style.background = event.color;
div.innerHTML = event.title;
// store the Event Object in the DOM element so we can get to it later
$(div).data('eventObject', eventObject);
$(div).draggable({
helper: function () {
$copy = $(this).clone();
$copy.data('eventObject', eventObject);
$copy.css({ "list-style": "none", "width": $(this).outerWidth() }); return $copy;
},
appendTo: 'body',
zIndex: 999,
revert: true, // will cause the event to go back to its
revertDuration: 0 // original position after the drag
});
$(className).append(div);
$(div).qtip({
content: event.title,
position:
{
target: 'mouse'
},
// show: { event: 'click' },
hide: { event: 'mousedown mouseleave' },
style: {
classes: 'custSideTip',
width: 200,
padding: 5,
color: 'black',
textAlign: 'left',
border: {
width: 1,
radius: 3
}
}
});
return div;
}
如您所见,每个事件都有一个项目属性
但是,也有一些项目和任务(以及可以忽略的案例):
以下是我不确定如何做的需要:
我需要一个基于OR的过滤器:
鉴于以下情况:
function filter(criteria,projects-div,tasks-div)
{
var words = criteria.split(' ');
}
我需要先隐藏所有的项目
对象数据('eventObject')。标题包含一个或多个单词
然后,过滤这些内容后:
我需要首先显示项目可见的所有任务
因此:
obj.data('eventObject')。项目是==可见项目的项目属性之一
然后,我还需要显示包含任何单词的任何任务
所有比较也必须不区分大小写
所以说我的标准是“你好,世界”
I show all projects with hello or world in the title.
I show all tasks whos project attribute is visible after the first step
I show all tasks whos title has hello or world
谢谢我在手机上,但乍一看呢?我在手机上,但乍一看呢?我在手机上,但乍一看,怎么办呢?我在手机上,但乍一看,
[]呢。过滤器。打电话(NodeList,filterFn)
你能把这个写进回答吗?哇,我完全错过了这个评论。我在手机上,但乍一看,[]呢。过滤器。呼叫(NodeList,filterFn)
你能把这句话写进回答吗?哇,伙计,我完全错过了这句话。
I show all projects with hello or world in the title.
I show all tasks whos project attribute is visible after the first step
I show all tasks whos title has hello or world