Problem using variable in selector
I've set some hidden input variables to help users search through a very dense page. If I hard code a string such as CHI it works, but if I pass CHI in as a variable it won't work.
Interestingly, I've not had issues doing this when I am passing in a variablel and trying to selection with an ID versus attribute selector.
Examples of what works:
A) hardcode selector by attribute: var targetOffset = $("input[value='CHI']").next().offset().top;
B) variable passed to selector by id: $.post(url, $("#"+formName).serialize(),function(data){
What I've tried to get selector by attribute with variables (all don't work):
A) var targetOffset = $("input[value="+str+"]").next().offset().top;
B) var targetOffset = $("input[value='"+str+"']").next().offset().top;
C) about a million variations of this where I take everything and try to put it into a variable --> var targetOffset = $(str).next().offset().top;