How can I gain access to a PHP variable from an external javascript (my.js) file? I want to get the dynamic id or class into external js file
PHP
<div id="tabs<?php echo str_replace(' ', '',$child1['id']); ?>" class="<?php echo $activetab1; ?> tab-pane">
<?php if ($child1['children1']) { $category2=$child1['children1']; ?>
<ul class="tabs<?php echo str_replace(' ', '',$child1['id']); ?>" id="tabs<?php echo str_replace(' ', '',$child1['id']); ?>" data-count="15">
<?php foreach ($category2 as $child2) { ?>
<li>
<?php echo $child2['name']."------------main"; ?>
</li>
<?php if ($child2['children9']) { $category9=$child2['children9']; ?>
<?php foreach ($category9 as $child9) { ?>
<li>
<?php echo $child9['name']; ?>
<?php echo str_replace(' ', '',$child1['id']); ?>
</li>
<?php } } ?>
<?php } ?>
</ul>
<?php } ?>
</div>
External JavaScript
var container = $("ul.tabs25"),
count = container.data("count"),
column;
container.children().each(function(index) {
if (index % count == 0)
column = $("<li/>").css({"float": "left", "margin-right": "50px"}).appendTo(container);
var hello=$(this).appendTo(column);
console.log(hello);
});
I want to dynamically change this $child1['id'] within JavaScript.
tabs25within JavaScript. What will it be? Access a Variable or changetabs25? if the former (access a variable); which variable? is it the $child1['id'] that you want to expose?