code not working when jquery version is changed -
Using an example code given on jsfiddle, clicking on one of the other checkboxes unchecked checkboxes works fine But when I do Jquery version 1.10.1, this does not work, a solution
$ (". Chb"). Every (function () {$ (this) .change (function () {$ (". Chb"). Attr ('checked', false); $ (this) .attr ('checked', true);}) ;}); Here is the link
Since you are not changing the attribute, use of the property will work with this version 1.10 +
$ (".chb") instead of the jQuery prop method. Each (function () {$ (this) .change (function () {$ (". Chb") prop ('check', false), $ (this) .prop ('check', correct);}); }); The difference between the attribute and the property
The attributes are usually defined by HTML, while properties are defined by dom for certain elements and The attributes represent the same (such as the ID of an element). The following is a good way to show DOM interaction:
& lt; Input type = "text" value = "some value" & gt; This element has two attributes ( type , text ). When the browser parses the document, then this property will create an object for this specific element with the type and value . If you type something in it, this element will affect property value value : input. GetAttribute ('value') / / - & gt; When trying to retrieve, you can see a better difference. Inital value will return: "some values" input.value // - & gt; Returns the value property of the object (the text you entered)
Comments
Post a Comment