Answer to Question #328867 in HTML/JavaScript Web Application for Bylapati suresh kumar

Question #328867

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>


1
Expert's answer
2022-04-16T03:46:31-0400

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

)};

});


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS