0

at 1st kindly visit this fiddle:

http://jsfiddle.net/Y4LMX/

I was wondering is there a way to transfer the click? I meant, when I click on the green area ( <div class="arrow"/> ) in the meantime the wi<select> tag also get clicked, or selected and shows the options bellow. Is there a way to do this?

NB: I am doing this for IE supported <select> tag.

I tried with the following code:

$(".ie-arrow").click(function(){
     $(this).prev().find($("select").click());
});

but, It's not working. Can you solve it?

Thanks.

Asif
  • 716
  • 2
  • 15
  • 37

4 Answers4

2

You could see this answer

https://stackoverflow.com/a/10844589/336542

A click on the select won't open it you have to change the size of it.

Community
  • 1
  • 1
sergioadh
  • 1,461
  • 1
  • 16
  • 24
1

You should try select dropdown plugins like dropkick.js

http://jamielottering.github.io/DropKick/

user1
  • 1,063
  • 1
  • 8
  • 28
1

I did it with size changing hack here: http://jsfiddle.net/f2Upx/

$(".drop1, .drop2").append("<div class='arrow' />");

$(".arrow").click(function(){
     $(this).prev().attr('size',5).css("height","200px")
            .parent().css("height","150px");
});

Also here's a simple example with fake selectbox I did couple of days ago http://jsfiddle.net/Jc2qq/ it would be easy to remake to suit needs of this question.

Goran Lepur
  • 594
  • 1
  • 4
  • 15
1

Okay, following the Idea from answer no. two of this question, here is a solution: Visit this fiddle

javascript:

$(".drop1").append("<div onclick='runThis1()' class='arrow'></div>");
$(".drop2").append("<div onclick='runThis2()' class='arrow'></div>");

(function () {
        showDropdown = function (element) {
            var event;
            event = document.createEvent('MouseEvents');
            event.initMouseEvent('mousedown', true, true, window);
            element.dispatchEvent(event);
        };

        window.runThis1 = function () {
            var dropdown = document.getElementById('dropdown');
            showDropdown(dropdown);
        };

        window.runThis2 = function () {
            var dropdown = document.getElementById('dropdown2');
            showDropdown(dropdown);
        };
    })();
Community
  • 1
  • 1
Asif
  • 716
  • 2
  • 15
  • 37