shinve — 2012-03-05T11:15:44-05:00 — #1
I have a simple auto complete where I'd like to make changes to the result display.
Here is the basic code.
This currently works fine, but I'd like to make the results alternatively highlight every row. So if the letter m was entered, this might appear:
Maggie (highlighted in color 1 or with class 1)
Margaret (highlighted in color 2 or with class 2)
Mary (highlighted in color 1 or with class 1)
Can someone tell me how I might accomplish this?
paul_wilkins — 2012-03-05T18:53:20-05:00 — #2
I believe that CSS3 has an :nth-of-type(odd) selector, so you should be able to make good use of that to color every odd one, with another default color that would apply to the even ones.
shinve — 2012-03-05T19:30:29-05:00 — #3
You are right, and that is what I thought to do too, but I don't know what to hook the css to. I don't know what class to apply it to (if there even is one). Do you have any thoughts here?
paul_wilkins — 2012-03-05T19:44:00-05:00 — #4
Do you have an example of the page as it currently is?
shinve — 2012-03-05T20:54:01-05:00 — #5
There's not much to show. I am testing out jquery autocomplete before I integrate it into the actual site. It's just a totally bare bones page with jquery included and a form field.
I can add anything to it you might suggest. I was hoping that jquery might have provided the means to do this though and I was just overlooking something I could hook my css onto, but I don't know.
paul_wilkins — 2012-03-06T01:24:53-05:00 — #6
Yes, jQuery provides a means to do that, with its :odd selector.