【发布时间】:2021-08-23 23:41:22
【问题描述】:
这是我的代码,
if(data.country_name == 'India'){
$('.fact').append("<h2 id='india'>Fact about India</h2>");
$('.fact').append("<p>The world's highest cricket ground is in Chail, Himachal Pradesh. Built in 1893 after leveling a hilltop, this cricket pitch is 2444 meters above sea level.</p>");
$(.fact).append('<p>2</p>')
$(.fact).append('<p>3</p>')
$(.fact).append('<p>4</p>')
console.log('this a india');
} else if(data.country_name == 'Turkey'){
$('.fact').append("<h2 id='turkey'>Fact about Turkey</h2>");
$('.fact').append('<p>The story of Santa Claus originated in Turkey</p>');
}else if(data.country_name == 'Russia'){
$('.fact').append("<h2 id='russia'>Fact about Russia</h2>");
$('.fact').append('<p>Russia is home to some 20 percent of the world’s trees, and one-fifth of the world’s freshwater is in Lake Baikal.</p>');
}
现在,如果我在 class='fact' 中为印度的事实添加 4 个<p>,那么只要客户位置是印度,它就需要从 if 语句中随机显示 1 个<p>
任何人都可以帮忙,我把它弄复杂了,我知道它可能太简单了!!
【问题讨论】:
标签: javascript html jquery web