dimanche 6 juin 2021

How do I change or update tag data with every client request

there is my code,

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>');
    }

now, if I add 4 <p> for India's fact in the class='fact', so whenever the client location is India, it needs to show 1 random <p> from the if statement

anyone can help, I make it complicated, I know it may be too simple!!




Aucun commentaire:

Enregistrer un commentaire