jQuery select where attribute = value

后端 未结 2 1216
挽巷
挽巷 2021-01-13 08:23

I am trying to select an input where the value equals a dynamic value

trimmed = jQuery.trim(a);
preSelectedCheckBox = $(this).find(\"input[value=\" + trimmed         


        
相关标签:
2条回答
  • 2021-01-13 08:43

    Are you just missing the enclosing single quotes?

    trimmed = jQuery.trim(a);
    preSelectedCheckBox = $(this).find("input[value='" + trimmed + "']");
    
    0 讨论(0)
  • 2021-01-13 08:46
    preSelectedCheckBox = $(this).find("input[value=" + trimmed + "]");
    

    forget the '' around the value

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