JQuery :contains function limit to exact match

后端 未结 3 1254
走了就别回头了
走了就别回头了 2020-12-11 04:24

Using the JQuery :contains function to decide which option on a select is selected from a SESSION variable.

The contains function is matching the wrong option as the

3条回答
  •  既然无缘
    2020-12-11 05:01

    Try using .filter(), to find the option you want.

    $('option').filter(function(){
        return $(this).html() == "";
    }).attr('selected', 'selected');
    

提交回复
热议问题