echo a javascript function with parameters in php
<p>I am trying to pass a JavaScript function with an onclick event in php. The problem I am facing is that the function that I need to pass has a parameter that needs to be in double quotes as follows:</p>

<pre><code>onclick="removeElement("div8")"
</code></pre>

<p>Now when I use JavaScript to generate the parameter it comes out fine, but whenever I use an echo function in php, the following happens when I look at the function in the browser</p>

<pre><code>onclick="removeElement(" div8")"
</code></pre>

<p>the code I am using to generate this is:</p>

<pre><code>echo '&lt;div&gt;&lt;img src="img.png" alt="image" onclick="removeElement("div'.$x.'")" /&gt;&lt;/div&gt;';
</code></pre>

<p>where $x is the number to be added to the parameter.</p>

<p>Is there a way that the function is returned as a whole and not get the space in between?</p>
