HTML
double&
JS
<div class="slider-container slide-0" num-slides="5" rel="0"></div>
目前:
当我在Google Chrome 64.0中运行该程序时,parseInt和Number不会返回数值。但是,当我在dev工具控制台中输入代码时:
var maxNum = parseInt($('.slide-0').attr("num-slides"));
// maxNum = NaN
var maxNum = parseInt($('.slide-0').attr("num-slides").value);
// "Uncaught TypeError: Cannot read property 'value' of undefined"
var maxNum = parseInt($('.slide-0').attr("num-slides").val());
// Uncaught TypeError: Cannot read property 'val' of undefined
var maxNum = Number($('.slide-0').attr("num-slides"));
// maxNum = NaN
为什么会出现这种情况?