问题描述
我在HTML中有这些动态生成的div,并填充了PHP数据:
<?php foreach (get_all_locations() as $cards) : ?>
<div class="block">
<div class="centered">
<div class="div_container">
<p class="location_id_el"><?php echo $cards['id']; ?></p>
<span onclick="edit_button_request(<?php json_encode($cards); ?>)"><i class='fas fa-edit'></i></span>
<p><?php echo $cards['name']; ?></p>
<div id="main_address_div">
<div id="address_div">
<p><?php echo $cards['streetname'] . ' ' . $cards['streetnumber'] . ' '; ?></p>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
现在,我想使用Java脚本导航到特定的div:
function myNavFunction(){
let i = document.getElementById('location_id_el').value; //here I get the id of that element
if(i === 4) document.location.href = ""; //here I want to navigate to the parent div of that element
}
有什么建议吗?!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)