I create an attribute called "hasAgreed" to check whether I should treate or dismiss the values of a form. I used this instead of relying on the click of the OK button since I want to be able to close the form sometimes when the user press Enter in the text input.
The problem I have is that if I do $('#formElement').attr('hasAgreed')
, I get diff开发者_如何转开发erent values.
Firefox returns a string "true" ( $('#formElement').attr('hasAgreed') == 'true')
IExplorer returns a boolean true
, ($('#formElement').attr('hasAgreed') == true)
Chrome seems to be fine with both versions.
Is there a way to set a bool value using the attr()
function of jQuery so that is consistent accross multiple browsers?
精彩评论