jQuery select option elements by value

前端 未结 8 1088
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 11:50

I have a select element wrapped by a span element. I am not allowed to use the select id but I am allowed to use the span id. I am trying to write a javascript/jquery functi

相关标签:
8条回答
  • 2020-12-04 12:35
    function select_option(index)
    {
        var optwewant;
        for (opts in $('#span_id').children('select'))
        {
            if (opts.value() = index)
            {
                optwewant = opts;
                break;
            }
        }
        alert (optwewant);
    }
    
    0 讨论(0)
  • 2020-12-04 12:37
    options = $("#span_id>select>option[value='"+i+"']");
    option = options.text();
    alert(option); 
    

    here is the fiddle http://jsfiddle.net/hRFYF/

    0 讨论(0)
提交回复
热议问题