私は二つのフィルターのためのjQueryのセレクタジェネレータを作成しようとしている - 狙いはちょうどカレンダーのいくつかの要素をhiddingされる -マージjqueryのセレクタ[javascriptの文字列の連結]
私はDB_ID 2グループにフィルタを適用した場合私はpersonn DB_IDをフィルタ場合#mod_calendar .gid_2
:私はグループDB_ID 2でフィルタリングした場合、私は、次のセレクタを生成したい #mod_calendar .gid_2.pid_1
:とpersonn DB_ID 1に私は次のセレクタを生成したいと思い1次のセレクタを生成したい:#mod_calendar .pid_1
IグループDB_ID 2,5,6,8上及びpersonn DB_ID 1でフィルタリングした場合、私は、次のセレクタ生成したい: #mod_calendar .gid_2.pid_1,#mod_calendar .gid_5.pid_1,#mod_calendar .gid_6.pid_1,#mod_calendar .gid_8.pid_1
Iがグループにフィルタ場合DB_ID 2,5 、私は次のセレクタを生成したいと思い6,8とpersonn DB_ID 1,2上: #mod_calendar .gid_2.pid_1,#mod_calendar .gid_5.pid_1,#mod_calendar .gid_6.pid_1,#mod_calendar .gid_8.pid_1#mod_calendar .gid_2.pid_2,#mod_calendar .gid_5.pid_2,#mod_calendar .gid_6.pid_2,#mod_calendar .gid_8.pid_2
だから1は、私はあなたがポイントを得ると思います... このhttps://jsfiddle.net/5mr60f6p/1は私がこれまで試したものですが、私は今のところこだわっている。
[EDIT]
<div id="mod_calendar">
<div class="pid_1 gid_1">pid_1 gid_1 [do not match gid_filter should not be shown]</div>
<div class="pid_2 gid_2">pid_2 gid_2 [do not match pid_filter should not be shown]</div>
<div class="pid_5">pid_5 [do not match gid_filter should not be shown]</div>
<div class="pid_5 gid_2">pid_5 gid_2 [match gid_filter and pid_filter should be shown]</div>
</div>
JSコード:私はこの正確なexemple、これら二つの配列で取得したい何
var pid_filter= [5,32,56,8,4];
var gid_filter=[2,5];
function generate_filter_selector(prefix,values){
return prefix+values.join(','+prefix);
}
console.log($(generate_filter_selector('#mod_calendar .pid_',test)).show());
//I would like the intersection of both selector and not like I did one after the other.
console.log($(generate_filter_selector('#mod_calendar .gid_',test2)).show());
このです:
$("#mod_calendar pid_5.gid_2,#mod_calendar pid_32.gid_2,#mod_calendar pid_56.gid_2,#mod_calendar pid_8.gid_2,#mod_calendar pid_4.gid_2,#mod_calendar pid_5.gid_5,#mod_calendar pid_32.gid_5,#mod_calendar pid_56.gid_5,#mod_calendar pid_8.gid_5,#mod_calendar pid_4.gid_5").show();
私がコメントで言ったように、私はbの交差点を持っていたいと思いますフィルタ。私の問題を理解する人のために
私はあなたが何を求めているのか、何が問題なのかは分かりません。フィドラーには2つの文字列を連結する1行のコードがあり、私たちは何をしたいのですか?質問をより明確にし、より多くのコードと特定の問題を表示できますか? – Esko
@Esko私の投稿を編集しました – Su4p