I am creating a simple webpage with a calender showing today's date. On this webpage, I also want to put a button that, once clicked, displays the name of a famous person whose birthday it is on this day. To do this, I want to get data from famousbirthdays.com. I have noticed a pattern with the urls on this site and to get the birthdays for any day, all I have to do is type
"https://www.famousbirthdays.com/" + month + day + ".html"
However, I am completely lost at what to do from here. So far, I have done this, but it doesn't work:
function celebBirthday(){
var url = "https://www.famousbirthdays.com/";
var birthday = currentMonth.toLowerCase() + "" + currentDate;
// gets famous birthdays page of current date using JQuery (I think)
$.get(url + birthday + ".html", function(response) {
console.log(response);
});
// "name" is the div class I am looking for
var name = $(response).find("name");
// should set the <p> tags to the celebrity's name
setText("celebName", name);
}
I know I am making a mistake in getting the class name. Currently, I am using the inspect element function on the website to see the html. How do I specify that I want the name of the first person on that webpage (i.e the most famous person whose birthday it is that day) ?