I am calling the JavaScript-function getElementById. As transfer parameter I want to use the PHP-Variable $currentTab
var currentTab = document.getElementById(<?php $currentTab ?>);
You need to add quotes, and output your variable with echo
. Maybe add the #
character if it is not in your php variable
document.getElementById('<?php echo $currentTab; ?>');
只需在'
<?php $currentTab ?>
周围添加'
或"
,以使getElementById()
接受字符串。而在javascript中,字符串则由'
或"
代替。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.