jquery selection if option.value equal something, mark a selected

前端 未结 6 758
说谎
说谎 2021-02-12 19:45

I have some question about jquery selection. In my case, how to match if the option.value equal something, mark a selected for it. Online code here

6条回答
  •  鱼传尺愫
    2021-02-12 20:05

    Your problem starts here

    $("div#selection select.select option").each(function(){ if((this).val()==num){

    change it to

    $("div#selection select.select").each(function(){
    if($(this).val()==num){
    

    and all your problem solved. You might want to change the .each to .change if you are thinking of having the script triggered everytime the selection is changed.

提交回复
热议问题