嘿伙计们,我希望传感器默认隐藏,当我点击特定节点时它会显示......并且在页面重新加载时应该是相同的 这是我的代码
<ul >
<?php if(isset($nodes)): ?>
<?php $count = 0; ?>
<?php foreach($nodes as $node) { ?>
<?php $node_id=$node['node_id']; ?>
<?php $sensors = config_sensor_model::getsensors($node_id); ?>
<?php $count++; ?>
<li onclick="menu(<?php echo $count; ?>)"><a href="#"><?php echo $node['node_name']; ?> </a></li>
<ul id="<?php echo "sub_".$count; ?>">
<?php foreach($sensors as $sensorlog) { ?>
<li><a href="<?php echo site_url(); ?>/dashboard/dashboard_graph/?node=<?php echo $node['node_id']; ?>&sensor=<?php echo $sensorlog->sensor_index; ?>&range=0&xticker=2&plot_graphs_value=1"> <?php echo $sensorlog->sensor_name; ?></a></li>
<?php } ?>
</ul>
<?php } ?>
<?php endif; ?>
</ul>
</div>
这是我目前正在使用的 javascript
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
function menu(count)
{
$("#sub_"+count).toggle("fast");
}
</script>