var aVN = 'CET', 'July', 'Birthday', '20110704', 'CGT', 'July', 'Anniversary', '20110705' ; function displayEvent(text)..." />

How to compare all the IDs of with an array of javascript or jquery?

Script type="text/javascript"> var aVN = 'CET', 'July', 'Birthday', '20110704', 'CGT', 'July', 'Anniversary', '20110705' ; function displayEvent(text) { // I'm not sure what you wanted to do here console. Log(text); } $(function() { $('li. Menu').

Click(function() { for (var I = 0; I 1 2 3 4 5.

1 2 3 4 5 Live demo. (Thanks to Damon for pointing out that IDs may not start with a numeric character. ).

That's just not true in HTML5. – Matt Ball Jul 20 at 14:14 @Matt: Not everybody is using HTML5. – Tomalak Geret'kal Jul 20 at 14:18 Hmm, there's an issue with the closure here.

– Tomalak Geret'kal Jul 20 at 14:18 Fixed it by inverting the lookup. – Tomalak Geret'kal Jul 20 at 14:22 this is what I wanna do...I have made a calendar..each day is made up of 's...like the example above...Now my main aim is to check if the date in the array matches the date id of the ....if it matches (for example if "20110705" from the array matches the with id "menu_20110705") then the color of that should change and the other data from the array i. E: birthday should be displayed on mousehover – user550884 Jul 21 at 11:23.

$('#thismonth > ul > li'). Each( function() { for (i in aVN) { if ($(this). Attr('id') == aVNi3) $(this).

Click(function() { window. Alert(aVNi2); }); } }).

2 Don't use for .. in with arrays. – Tomalak Geret'kal Jul 20 at 14:12.

More "jquerysh" approach would be setting some class with common prefix and unique postfix (.allineed-1, . Allineed-2 etc) and then finding content using appropriate css selector - $(document. Body).

Find(". Allineed-" + id). Nevertheless, if you insist, you can use ids the same way.

Besides, not sure, but looks like you'd better keep a hash instead of array, since ids are unique (if we do not care about ordering). It would be a bit easier to perform inverse action - to map lis for some data. Keeping in mind that, again, there are some more "jquerysh" approaches - using data to associate dom object with some, well, data ))).

Why would you ever use $(document. Body). Find(".

Allineed-" + id) instead of $(". Allineed-" + id)? – Matt Ball Jul 20 at 14:24 @Matt Ball - just to illustrate that we can pass context.

– shabunc Jul 20 at 14:27 this is what I wanna do...I have made a calendar..each day is made up of 's...like the example above...Now my main aim is to check if the date in the array matches the date id of the ....if it matches (for example if "20110705" from the array matches the with id "menu_20110705") then the color of that should change and the other data from the array i. E: birthday should be displayed on mousehover – user550884 Jul 21 at 11:24.

Var aVN = 'CET', 'July', 'Birthday', '20110704', 'CGT', 'July', 'Anniversary', '20110705'; $('li:has(ul)'). Delegate('ul > liid', 'click', function () { var myId = this. Id; for (var i=0; iLength; i++) { if (myId === aVNi3) { alert(aVNi2); // or whatever break; } } }); Demo: http://jsfiddle.net/mattball/E5F4e.

Why delegate?... – mplungjan Jul 20 at 14:10 To reduce the number of event listeners created. – Matt Ball Jul 20 at 14:13 THANKS FOR ALL YOUR ANSWERS.... – user550884 Jul 21 at 9:54 this is what I wanna do...I have made a calendar..each day is made up of 's...like the example above...Now my main aim is to check if the date in the array matches the date id of the ....if it matches (for example if "20110705" from the array matches the with id "menu_20110705") then the color of that should change and the other data from the array i. E: birthday should be displayed on mousehover – user550884 Jul 21 at 11:22.

Try this aVN = new Array(); aVN. Push(new Array('CET', 'July','Birthday', '20110704')); aVN. Push(new Array('CGT', 'July','Anniversary', '20110705')); for(var I = 0;iLength;i++){ if($("#"+avNi3).

Length){ $("#"+avNi3). Click(function(){ alert(avNi2); } } }.

You have syntax errors, and you're using a poor method of creating arrays. – Tomalak Geret'kal Jul 20 at 14:09 this is what I wanna do...I have made a calendar..each day is made up of 's...like the example above...Now my main aim is to check if the date in the array matches the date id of the ....if it matches (for example if "20110705" from the array matches the with id "menu_20110705") then the color of that should change and the other data from the array i. E: birthday should be displayed on mousehover – user550884 Jul 21 at 10:41 this is what I wanna do...I have made a calendar..each day is made up of 's...like the example above...Now my main aim is to check if the date in the array matches the date id of the ....if it matches (for example if "20110705" from the array matches the with id "menu_20110705") then the color of that should change and the other data from the array i.

E: birthday should be displayed on mousehover – user550884 Jul 21 at 11:24 @User - Did this helped you? – ShankarSangoli Jul 21 at 12:04.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions