开发者

Boolean Attributes with jQuery is inconsistent accross Browsers

开发者 https://www.devze.com 2023-03-17 04:51 出处:网络
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 clos

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消