jeudi 16 avril 2015

Javascript Event Binding does not work correctly?


Vote count:

0




I have created a list (navigation menu) with 2 different rows. Each of this row is connected to a diagram. For instance row 1 (Temperature) is connected to Temperature diagram (table1 and table2).


I want the user to decide which table to view by clicking on the navigation menu, and if the person wish to view another table the first diagram has to be closed before the next one comes up. So what do I have to do in javascript (JQuery) in order to do this link up the row1 with the table1 and row2 with table2?


The problem is that when I click on the next row, nothing happens.


This index.html:



<!--Link to tables-->
<script type="text/javascript" src="js/diagram1"></script>
<script type="text/javascript" src="js/diagram2"></script>

</head>
<body>

<div id = "diagram1"></div> <!--Import html file for chartcontainer-->
<div id = "diagram2"></div> <!--Import html file for chartcontainer-->
</body>


This is javascript inside another file where I have included in index.html.



<ul class="list-group">
<!--Set this inside a div to individuelly choose-->
<div id = "1"><li class="list-group-item">Exhaust Temperature</li></div>
<div id = "2"><li class="list-group-item">Cylinder Pressure</li></div>
</ul>
</div>
</div>

</div> <!-- end row -->
</div> <!-- container -->

<script>
$(function(){
$('#1').on('click',function(){
$('#table1').toggle();
});

$('#2').on('click',function(){
$('#table2').toggle();
});
});


Kind regards Dler H.



asked 4 mins ago







Javascript Event Binding does not work correctly?

Aucun commentaire:

Enregistrer un commentaire