// 定义宠物档案数据const petProfiles = [
{ id: 1, name: '豆豆', species: '狗', breed: '博美', owner: '张三' },
{ id: 2, name: '咪咪', species: '猫', breed: '英短', owner: '李四' },
{ id: 3, name: '毛毛', species: '兔子', breed: '垂耳兔', owner: '王五' }];// 展示宠物档案的函数function displayPetProfile(petId) {
const petProfileDiv = document.getElementById('petProfile');
const selectedPet = petProfiles.find(pet => pet.id === petId);
petProfileDiv.innerHTML = `<h3>${selectedPet.name}</h3><p>物种:${selectedPet.species},品种:${selectedPet.breed},主人:${selectedPet.owner}</p>`;}// 调用展示函数displayPetProfile(1);
暂时没有评论,来抢沙发吧~