在jQuery中使用php添加div类

My variable contains a color name. My example:

<?php
$myvar = blueColour;
?>

I need to add this value to body of a html page using jQuery:

<script type="text/javascript">
jQuery(body).addClass("<?php echo $myvar; ?>");
</script>

Can I use php inside jQuery this way? Thank you.

EDIT: its an wordpress site. I use this in a if to add that class on a specific page template.

<script type="text/javascript">
jQuery("body").css("color", "<?php echo $myvar; ?>");
</script>

yes, as long as your html file is interpreted by php (having .php/.phtml extension)

I did it. Worked. Correct is:

jQuery('body').addClass("<?php echo $myvar; ?>");

with

jQuery('body')

not

jQuery(body)
if ( is_page_template('nameOfYouTemplate.php') ) {

    echo '<body class='. $myvar .'>';

 } else {
    echo '<body>';
 }