Newbie Newbie - 13 days ago 9
C# Question

Why Is .data not Working?

Newbie here, I've been on this for over 2 hours! :(

If anyone can tell me why this isn't working I will be forever indebted to you :)

@foreach (var c in Model.Cleaner.TimeConfirmations)
{
<label class="glyphicon glyphicon-remove-circle cancelTime thex" data-timeid="12"></label>
}

}


then jquery

$(".thex").on('click', function () {
var id = $(this).data("timeId")
alert(id);

});


why is id undefined?!?!?!?!?!

Answer

Case sensitive error.

Working Fiddle

$(".thex").on('click', function () {
    var id = $(this).data("timeid")
    alert(id);
});