Hey guys can someone tell me how to add double quote on style=""
in order for my jquery to work.
PHP code - Didnt work
echo" <div class='fill' style='background-image:url('image/".$row["image"]."');'></div>";
HTML Code - This work
<div class='fill' style="background-image:url('image/img.jpg');"></div>
I know that I can add escape it using \"
but I already tried that but its still didnt work.
Either of these methods should work. Effectively, you cannot use the same style quote inside the same style quote - so it must be escaped.
echo" <div class='fill' style='background-image:url(\'image/".$row["image"]."\');'></div>";
echo" <div class=\"fill\" style=\"background-image:url('image/".$row['image']."');\"></div>";
As an alternative, for when you're dealing with strings that use both types of quotes, consider using a heredoc:
echo <<<EOL
<a href="javascript:alert('hi mom!')">click me</a>
EOL;
No need to escape any of the quotes in this case.