I'm working in Drupal with jQuery. How do I insert a php $variable into a tag.
$(document).ready(function(){
$("#comment-delete-<?php print $variable ?>").click(function(){
$("div.comment-<?php print $variable ?> span.body").replaceWith("new text");
});
})
or
$(document).ready(function(){
$("#comment-delete-". $variable).click(function(){
$("div.comment-". $variable ." span.body").replaceWith("new text");
});
})
A few things to clearify. I'm running in Drupal, so the full code looks like this:
<?php
drupal_add_js (
'$(document).ready(function(){
$("#comment-delete-"' print $comment->cid; ').click(function(){
$("div.comment-"' print $comment->cid; '" span.body").replaceWith("<span style=\'color: grey;\'>Please wait...</span>");
});
})',
'inline');
?>
but it's still not working.
Update: I tried the following, but it's still not working
<?php
$testing = "42";
drupal_add_js (
'$(document).ready(function(){
$("#comment-delete-"'. $testing .').click(function(){
$("div.comment-"'. $testing .'" span.body").replaceWith("<span style=\'color: grey;\'>Please wait...</span>");
});
})',
'inline');
?>
If I use the number "42" instead of the variable, it works, but not when using the variable... weird.