开发者

jQuery select where attribute = value

开发者 https://www.devze.com 2022-12-11 17:50 出处:网络
I am trying to select an input where the value equals a dynamic value trimmed = jQuery.trim(a); preSelectedCheckBox = $(this).find(\"input[value=\" + trimmed + \"]\");

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

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

T开发者_StackOverflowhe element exists but I constantly get no value returned. ($(preSelectedCheckBox).length = 0)


Are you just missing the enclosing single quotes?

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


preSelectedCheckBox = $(this).find("input[value=" + trimmed + "]");

forget the '' around the value

0

精彩评论

暂无评论...
验证码 换一张
取 消