【发布时间】:2013-01-22 15:28:36
【问题描述】:
我有以下html:
<div type="Text with spaces" eventid="57" class="movie">...</div>
如何使用 jQuery 读取 type 属性?
我试过了:
var type = $(".movie").attr("type");
但type 仅包含Text。
更新:
这就是我使用这个变量的方式:
$("#publicationBlock").load("/Publication/EventSchedule?eventId=" + eventId + "&type=" + type
在行动中,我只得到Text。
【问题讨论】:
-
您使用的是哪个版本的 jquery?上面的代码适用于 jq 1.7.2 和 1.8.3 甚至 1.6.4
-
您能否检查您的源 html 以确保值周围存在双引号
-
我刚遇到这个问题。这是由于没有在值周围使用引号引起的。
标签: jquery html asp.net-mvc