I am passing the ID of an element. At one point it no longer works. I think it needs to be forced to be seen as a string?

I am passing the ID of an element. At one point it no longer works. I think it needs to be forced to be seen as a string?

Hello all.

I have the following code that works if I hardcode the variable as I do here:

  1. function rw_getPositionOfPortfolioTarget(DivTargetPassed){
  2.         
  3.  // IF I HARDCODE THIS VAR HERE IT WORKS FINE
  4. var DivTargetPassed = "container_interactive";
  5.  
  6. var portfolioTarget = $("div[id*="+DivTargetPassed+"]");
  7. var portfolioTargetPosition = portfolioTarget.position();
  8. var portfolioTargetleftPosition = portfolioTargetPosition.left; 
  9. var portfolioTargettopPosition = portfolioTargetPosition.top;
  10. alert("left: " + portfolioTargetleftPosition + " top: " + portfolioTargettopPosition);
  11. };
Now if I pass the variable by getting the value from an attribute ID, it does not work. Please see the code that does this here

  1. function rw_PortfolioLinkControl(){
  2. $(".clickie").click(function(){
  3. var clickedPortfolio_Id = $(this).attr("id");
  4. rw_getPositionOfPortfolioTarget(clickedPortfolio_Id);
  5. });
  6. }
  7. function rw_getPositionOfPortfolioTarget(DivTargetPassed){
  8.        //THE FOLLOWING ALERT READS THE ID CORRECTLY
  9.                                alert(DivTargetPassed);
  10.  
  11. var portfolioTarget = $("div[id*="+DivTargetPassed+"]");
  12. var portfolioTargetPosition = portfolioTarget.position();
  13. var portfolioTargetleftPosition = portfolioTargetPosition.left; 
  14. var portfolioTargettopPosition = portfolioTargetPosition.top;
  15. alert("left: " + portfolioTargetleftPosition + " top: " + portfolioTargettopPosition);
  16. //return false;

  17. };


In Line 12 you can see in my comment that I my alert does read the correct ID name. It does not however translate when I try to use the value to make the dynamic target as seen in Line 15. 

This does work in the first code example when I actually pass the var value contained within quotes.

I am wondering if NOT giving it quotes in the second code block sample is the issue? 
Do I need to ADD quotes somewhere in Line 15?
Do I need to define the value as a string since it may be coming through as something else??

Thanks for your help!
RW