0

我从谷歌找到了这个脚本。但它不适用于tabindex。你能帮我解决这个问题吗?

这是jsfiddle链接

js片段:-

$('select').each(function () {

    // Cache the number of options
    var $this = $(this),
        numberOfOptions = $(this).children('option').length;

    // Hides the select element
    $this.addClass('s-hidden');

    // Wrap the select element in a div
    $this.wrap('<div class="select"></div>');

    // Insert a styled div to sit over the top of the hidden select element
    $this.after('<div class="styledSelect"></div>');

    // Cache the styled div
    var $styledSelect = $this.next('div.styledSelect');

    // Show the first select option in the styled div
    $styledSelect.text($this.children('option').eq(0).text());

    // Insert an unordered list after the styled div and also cache the list
    var $list = $('<ul />', {
        'class': 'options'
    }).insertAfter($styledSelect);
4

1 回答 1

0

需要用 jQuery 动态设置 tabindex。

//Adds tabindex dynamically 
$this.attr("tabindex", "0");

http://jsfiddle.net/elitownsend/BB3JK/4733/

于 2018-10-03T17:52:22.057 回答