I am writing PhoneGap application. I compile it using the PhoneGap Build web service. I have not included jQuery Mobile, though I have included jQuery in my project. In a pure web application I often use code like this:
<html>
<body>
<div class="button" id="button1">Hello</div>
<script>
$(".button").click(function() {
alert($(this).attr("id"));
});
</script>
</body>
</html>
However, in PhoneGap, I find that when I reference any attribute of my $(".button")
element via jQuery's $(this)
, the value of the attribute is undefined
. What should I do?