Before everything else, your HTML is not
properly complete.
<!--
<button type="button" value="favourites" id="favourites"></button>
Next, you are trying to see if there is a property "
i
", and if so, then what is the value. In your case, the property doesn't exist, thus it causes the
undefined
value to be returned. There are multiple solutions to this, and you can do this in many ways.
First one being that you add a property with key, "i".
<button type="button" value="favourites" id="favourites" i="valuestoshow"></button>
Otherwise, change the jQuery code and use the property key to render the information in the alert box. Something like this,
alert($(this).prop("value"));
alert($(this).prop("id"));
alert($(this).text());
That will give you an opportunity to understand how this works, and then proceed with the next logic inside your app.