JQuery select where attribute = value

I am trying to select an input where the value is equal to the dynamic value

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

The item exists, but I do not get any value. ($ (preSelectedCheckBox) .length = 0)

+4
source share
2 answers

Do you just miss single quotes?

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

forget '' around the meaning

+1
source

All Articles