prop

jQuery attr vs prop?

你。 提交于 2019-11-26 03:38:15
问题 Now this isn\'t just another What\'s the difference question , I have done some tests(http://jsfiddle.net/ZC3Lf/) modifying the prop and attr of <form action=\"/test/\"></form>​ with the output being: 1) prop Modification test Prop: http://fiddle.jshell.net/test/1 Attr: http://fiddle.jshell.net/test/1 2) Attr Modification test Prop: http://fiddle.jshell.net/test/1 Attr: /test/1 3) Attr then Prop Modification test Prop: http://fiddle.jshell.net/test/11 Attr: http://fiddle.jshell.net/test/11 4)

.prop() vs .attr()

二次信任 提交于 2019-11-25 22:10:18
问题 So jQuery 1.6 has the new function prop(). $(selector).click(function(){ //instead of: this.getAttribute(\'style\'); //do i use: $(this).prop(\'style\'); //or: $(this).attr(\'style\'); }) or in this case do they do the same thing? And if I do have to switch to using prop() , all the old attr() calls will break if i switch to 1.6? UPDATE selector = \'#id\' $(selector).click(function() { //instead of: var getAtt = this.getAttribute(\'style\'); //do i use: var thisProp = $(this).prop(\'style\');