How to convert string into boolean?
This question already has an answer here:
Try
<div id='test' data-nav='true'>
var truefalse = $('#test').data('nav');
.data should be able to evaluate it as boolean
here is an example in JSFiddle https://jsfiddle.net/lismore/hx3gLvgw/
链接地址: http://www.djcxy.com/p/75084.html上一篇: 为什么使用JavaScript eval函数是一个坏主意?
下一篇: 如何将字符串转换为布尔值?