Random activity
When the HTML button element with the id getActivity Btn is clicked, a GET request has to be sent to the given URL and set HTTP response value in the HTML paragraph element with id activityName, activityType and the HTML img element with id activity Img should change according to the response
<div class="bg-container text-center">
<button class="get-activity-button p-1 mt-3" id="getActivityBtn">Get Activity</button>
<div class="mt-2" id="result">
<div class="d-flex flex-row">
<div class="w-50 d-flex flex-column justify-content-center text-center">
<p id="activityName" class="activity-name">Buy a new house decoration</p>
<p id="activityType" class="activity-type">recreational</p>
</div>
var containerJqo = $(".bg-container");
var getActivityBtnJqo = container.find("#getActivityBtn");
getActivityBtnJqo.on("click", function () {
$.get(url, function(data) {
containerJqo.find("p#activityName").text(data.activityName);
containerJqo.find("p#activityType").text(data.activityType);
containerJqo.find("img#activityImg").attr('src', data.activityImg);
)};
});
Comments
Leave a comment