trigger click event on select
Hi everyone.
I have been trying to develop a simple method of styling the button on select dropdowns. Basically just positioning a span of the button on a select box that is styled as required.
That is trivial...
What I have so far failed to achieve is to get the select box to show its options when clicking this span - just want to have the select box drop down the options as it normally would.
tried .trigger('click') and .trigger('mousedown') but to no avail...
Here is what I have:
- $(document).ready(function(){
-
- $('select').after('<span class="cta arrow-down"></span>');
- $('input[type="submit"]').after('<span class="cta arrow-right"></span>');
-
- $('span.cta').each(function(){
- var $this = $(this);
- var $prev = $this.prev();
- var $dim = $prev.position();
- $this.css({'top':$dim.top, 'right':0, 'height':$prev.outerHeight(), 'width':$prev.outerHeight()});
- $this.click(function(){
- $prev.trigger('click');
- });
- });
- };
Any input from you guys would be very much appreciated. I'd very much like to avoid using the dropdownReplacment plugin if possible.
Many thanks.