Retrieve boolean data from data attribute in jquery

后端 未结 5 657
梦如初夏
梦如初夏 2020-12-14 05:34

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 .

H

5条回答
  •  粉色の甜心
    2020-12-14 05:59

    jQuery recognizes the string "true" as it's boolean counterpart (in the context of data attributes) and thus:

    typeof isreturn_str; // boolean
    

    but you're strictly comparing to the string 'true' which yields false as a string is not a boolean.

提交回复
热议问题