开发者

Why won't this jQuery Data example work?

开发者 https://www.devze.com 2023-01-29 19:16 出处:网络
This is MADDENING. Here is my html: <td>&开发者_如何学编程lt;a class=\"opener\" data-dialogid=\"dialog1\"><%= responsibility.user.email %></a></td>

This is MADDENING.

Here is my html:

<td>&开发者_如何学编程lt;a class="opener" data-dialogid="dialog1"><%= responsibility.user.email %></a></td>

And here is my jQuery code:

$('.opener').mouseover(function() {
    alert($(this).data("dialogid"));
    return false;
});

I have tried every possible iteration of that "alert" line above. I am basically trying to pass a data value to my Javascript. But it seems impossible. I am pulling my hair out, this is really, really frustrating.


You have data-dialogid, but it's looking for data-digitalid, make them match :)

For example:

$('.opener').mouseover(function() {
    alert($(this).data("dialogid"));
    return false;
});

Also note that this only works in jQuery 1.4.3+, you would need .attr("data-dialogid") before that.

0

精彩评论

暂无评论...
验证码 换一张
取 消