Jump to content

jQuery :eq on selection menu?


piearcy

Recommended Posts

Quick question that I have not been able to find on the internet. Go figure. 

 

Can you apply the jQuery :eq(index) to a selection menu? I use it for list items but have been unsuccessful at using it for a selection menu. Probably because they aren't an ordered list? 

 

So I've probably answered my own question there. 

 

What could I use in it's place for a selection menu? 

 

I'm indexing the actual line item referenced to know what to load thusly...

$('.tab-content div.tab:eq(' + $('#tab-menu > li').index(this) + ')').slideDown('slow');

Really need to do the same thing with a selection menu but google has not helped me out so far. 

 

 

Link to comment
https://forums.phpfreaks.com/topic/294866-jquery-eq-on-selection-menu/
Share on other sites

Have you tried this?

$('.tab-content div.tab').eq($('#tab-menu > li').index(this)).slideDown('slow');

Apparently you'll also get a performance boost (http://api.jquery.com/eq-selector/).

Yeah. Tried that. Gave up and decided to write longer code but it works. Just made a series of if else statements to determine with selection was selected and then do it's thing. I have no patience. Going to be slower but it is what it is I suppose. 

 

The problem with the above is it doesn't select the correct item. Always chooses the last one. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.