0
<div id="story">
<p data-x="0">lorem ipsum...</p>
<p data-x="3">lorem ipsum...</p>
<p data-x="10">lorem ipsum...</p>
</div>
$("#btnleft").click(function(){
var part = 1;
var a = $("#story > p").eq(part);
var b = a.dataset["data-x"];
console.log (b);
});
我希望3
結果,但控制檯說: Cannot read property 'data-x' of undefined
解決,非常感謝 – bonaca