This is something like jquery selectbox . For positioning the div replacing select , used offset() . I measure the width and height of selektov. As a result, divs are normally displayed. But the problem is that divas were higher than selektov. And lower them below, I can not. With z-index: -1; they leave for content. How to transfer click from diva to select?

Here is the code:

 // click send to replacer $('select').click(function(e) { $(this).next('.sel-wrapper').trigger('click'); // это не работает }); $('select').each(function(index, element) { var realSelect = $(this); if(!(realSelect.next('.sel-wrapper').length)){ realSelect.after('<div class="sel-wrapper"><div class="sel-body"></div><div class="sel-btn"></div></div>'); } // dimensions var selWrapper = realSelect.next('.sel-wrapper'); selWrapper.width(realSelect.width()); selWrapper.height(realSelect.height()); selWrapper.css({'border':'1px solid violet'}); // position var selectPos = realSelect.offset(); selWrapper.offset({top: selectPos.top, left: selectPos.left}); 

    1 answer 1

    Trigger - .trigger ()

    • See the code. The trigger is already there. He does not work. And with quotes and without. - Lucky
    • 2
      $ (this) .next ('. sel-wrapper'). length // If this returns a non-zero value (which I doubt), then I already don't see the handling of the click event on the sel-wrapper. And by the way. When writing a handler, write it using live (old jquery) or on (new). - knes