Nic*_*ver 94
您可以data-使用属性选择器选择属性,如任何其他属性.在这种情况下,您需要attribute-equals选择器,如下所示:
$("div[data-role='footer']")
Run Code Online (Sandbox Code Playgroud)
它们被特殊处理消耗的jQuery,例如,允许.data()从他们正确的打字取...但据DOM遍历推移,他们只是另一个属性,所以写选择器时把它们想象成这样的.
$('div[data-role="footer"]')
Run Code Online (Sandbox Code Playgroud)
这只是使用attribute-equals-selector(docs).
有几个属性选择,你可以使用(除其他).
jQuery Mobile推荐$ .fn.jqmData(),例如:$("div:jqmData(role ='footer')")
资料来源:http://jquerymobile.com/test/docs/api/methods.html