jQuery select option elements by value

前端 未结 8 1098
没有蜡笔的小新
没有蜡笔的小新 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:26

    Here's the simplest solution with a clear selector:

    function select_option(i) {
      return $('span#span_id select option[value="' + i + '"]').html();
    }
    

提交回复
热议问题