title: js - set var = width of element with jquery
body: <p>I have a script for outputting google map , and I am using infobox </p>
  
  <p>in my script , I have a "dnamic" width for the infobox, which works just fine .
  The problem is that I need to set the "close" button margins ..
  The infobox takes an element with class of "infobox".</p>
  
  <pre><code>var s_infobox_k = {
               content: "z",
               disableAutoPan: false,
               maxWidth: 0,
               zIndex: null,
               boxStyle: { 
               padding: "10px",
               width: "150px"
               },
               closeBoxMargin: "-14px", // &lt;-- HERE I NEED THE WIDTH OF THE DIV
               closeBoxURL: pluginDir + "/images/close.png",
                   isHidden: false,
               pane: "floatPane",
               enableEventPropagation: false
          };
  </code></pre>
  
  <p>basically I need the closeBoxMargin to be <code>" closeBoxMargin: "-14px InfoboxWidth()px",</code></p>
  
  <p>so I tired to set a VAR</p>
  
  <pre><code>var width_div = jQuery(\'.infobox\').width() ;
  </code></pre>
  
  <p>but for some reason it is only printing the exact same syntax in the JS . (e.g. in the JS i will see -  <code>var width_div = jQuery(\'.infobox\').width() ;</code> ) - literraly , instead of <code>var width_div = valuePx</code>.</p>
  
  <p>Is that some syntax error ? or am I doing something terribly wrong ? why is the var no getting set ?</p>
  
  <p><strong>EDIT 1 :</strong> </p>
  
  <p>This all javascript is being produced by an ultra simple php..</p>
  
  <pre><code>    function print_front_script() {
      return '
      &lt;script type="text/javascript"&gt;
              ... script here 
  &lt;/script&gt;
      ';}
  </code></pre>
  
  <p>there are absolutly no other problems ..
  even setting the var with PHP works great </p>
  
  <pre><code>closeBoxMargin: "-14px -'.((($this-&gt;innerthumbs_w)/2)+50).'px",
  </code></pre>
  
  <p>the problem is that PHP can not know the div width ...</p>
  
  <p><strong>EDIT II</strong> </p>
  
  <p>the full script can be viewed here :
  <a href="http://codepad.org/cC1qGPbV" rel="nofollow">http://codepad.org/cC1qGPbV</a></p>
  
  <p><strong>EDIT III</strong> 
  added the xHTML OUTPUT 
  <a href="http://codepad.org/YdnMoVLq" rel="nofollow">http://codepad.org/YdnMoVLq</a></p>