6.5.js 682 B

1234567891011121314151617181920212223
  1. $(document).ready(function() {
  2. $('#letter-a a').click(function(event) {
  3. event.preventDefault();
  4. $('#dictionary').load('a.html');
  5. });
  6. $('#letter-b a').click(function(event) {
  7. event.preventDefault();
  8. $.getJSON('b.json', function(data) {
  9. var html = '';
  10. $.each(data, function(entryIndex, entry) {
  11. html += '<div class="entry">';
  12. html += '<h3 class="term">' + entry.term + '</h3>';
  13. html += '<div class="part">' + entry.part + '</div>';
  14. html += '<div class="definition">';
  15. html += entry.definition;
  16. html += '</div>';
  17. html += '</div>';
  18. });
  19. $('#dictionary').html(html);
  20. });
  21. });
  22. });