I am trying to retrieve a data attribute of type Boolean from an html DIV element , however it is always returning false when the string is converted to boolean .
HTML
<div id='test' data-return="true"></div>
JS
isreturn_str = $('#test').data('return');
isreturn = (isreturn_str === 'true');
if (isreturn) {
document.write("It is true");
} else {
document.write("It is false");
}
output
It is false
http://jsfiddle.net/neilghosh/494wC/
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…