如何在php中使用多个类来响应jquery/javascript div?

如何在php中使用多个类来响应jquery/javascript div?,javascript,php,jquery,Javascript,Php,Jquery,我似乎只能添加一个类。无论我做什么,第二个类总是放在引号之外: <?php echo "$('.postcode').append( '<div class= " . 'errorpostcode' . " ".'test'.">Postcode- huisnummercombinatie niet gevonden</div>' );"; ?> 它应该如下所示: <?php echo "$('.postcode').append( '<d

我似乎只能添加一个类。无论我做什么,第二个类总是放在引号之外:

  <?php
echo "$('.postcode').append( '<div class= " . 'errorpostcode' . " ".'test'.">Postcode- huisnummercombinatie niet gevonden</div>' );";

?>

它应该如下所示:

<?php echo "$('.postcode').append( '<div class= \"" . 'errorpostcode' . " ".'test'."\">Postcode- huisnummercombinatie niet gevonden</div>' );"; ?>

生成和注入将HTML注入页面的javascript似乎有点过于复杂,您可能需要重新思考您正在做什么

也就是说,我想这就是你想要的

print("\$('.postcode').append(\"<div class='".$errorpostcode." ".$test."'>Postcode- huisnummercombinatie niet gevonden</div>\");");
打印(\$('.postcode')。附加(\'postcode-huissummercombinatie niet gevonden\”);

php生成的html如下所示:

<div class= errorpostcode test >

为什么不直接用PHP输出
div
?此外,您还可以将类位更改为:
class=\“errorpostcodetest\”
。问题是你的引号不匹配。请不要在你的问题上骂人。完全没有必要使用itOk,有时候你们几个小时都在盯着代码看,就是看不到明显的解决方案。选择code并按ctrl+k或单击
{}
按钮
<?php
echo "$('.postcode').append( '<div class=' " . 'errorpostcode' . " ".'test'."'>Postcode- huisnummercombinatie niet gevonden</div>' );";
?>
<div class="errorpostcode test">