Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery select where attribute = value

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

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

The element exists but I constantly get no value returned. ($(preSelectedCheckBox).length = 0)

like image 504
Paul Knopf Avatar asked Nov 19 '09 10:11

Paul Knopf


2 Answers

Are you just missing the enclosing single quotes?

trimmed = jQuery.trim(a);
preSelectedCheckBox = $(this).find("input[value='" + trimmed + "']");
like image 157
djdd87 Avatar answered Oct 06 '22 00:10

djdd87


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

forget the '' around the value

like image 25
Paul Knopf Avatar answered Oct 06 '22 00:10

Paul Knopf