jQuery1.7.2 Selected pulldown menu option value triggers link containing same rel (or name) value?
I am trying to trigger a link that has same rel or name value of selected option value of a pulldown menu, is the following code capable of doing thist?
- var s = $("this option:selected").val();
- $("a.track[rel='s']").trigger("click");
Basically you select an item from the pulldown menu and a matching link gets clicked. Scratching my head on this one (still learning). If above code is flawed, can you suggest some code that achieves what I need?
Thanks in advance. - dan
UPDATE: I got this function but it's not triggering the matching link. I gather I may have to find each link before any of them can be targeted?
Maybe reversing the order of this jsFiddle would do?
- $("option").change(function(event){ //when option is selected
- event.preventDefault();
- $("a.track").attr(name='$(this).val()').trigger("click");