Yes, there are similar questions, but they are about jquery adding lowercase attributes like here: Does the attr() in jQuery force lowercase?
But I have a different situation. Here is my HTML5 piece of code:
<tr class='projectRow' data-projectId='34'>
Notice that this is camelCase. And now this code does not work:
//"this" points to a child element
$id = $(this).closest('.projectRow').data('projectId');//undefined
But if I make it lowercase:
$(this).closest('.projectRow').data('projectid');
It works.
When I look at the source code, it's clearly "projectId" (camelCase), but when in chrome -> dev tools -> elements then it's "projectid" (lowercase) o_O
No wonder jquery can't get this value, but why is Chrome doing this? I did something similar hundreds of times before, although was using a - like in "project-id" and now after so many years of making web applications I discover something like this o_O
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…