BitelewlyBeno
New Member
BackgroundAs of jQuery 1.9 the \[code\].attr(..)\[/code\] method no longer returns property values, instead we now have to use \[code\].prop(..)\[/code\]. Unfortunately this also applies to attributes specified via an attributes selector i.e. \[code\]$("input[value=http://stackoverflow.com/questions/15513263/]")\[/code\]Seehttp://jquery.com/upgrade-guide/1.9/#attr-versus-prop-and a good SO discussion on the differences between \[code\].attr\[/code\] and \[code\].prop\[/code\] :.prop() vs .attr()My SituationI'm currently using selectors like \[code\]$("input[value=http://stackoverflow.com/questions/15513263/]")\[/code\] and \[code\]$("select[value=http://stackoverflow.com/questions/15513263/]")\[/code\] to select input elements that have no value set. However, this no longer works with jQuery 1.9, instead I'm now doing something like this:\[code\]var hasValue = http://stackoverflow.com/questions/15513263/function () { return !!($(this).val().length); };var hasNoValue = function () { return !($(this).val().length); };$("input").filter(hasValue);$("select").filter(hasValue);\[/code\]My actual selectors are a little larger, checking multiple elements with or without values so now I'm having to split my 1 selector string into multiple selectors with .filter(..) method calls in between. QuestionIs there an equivalent to \[code\]$("[value=http://stackoverflow.com/questions/15513263/]")\[/code\], \[code\]$("[value!=]")\[/code\], \[code\]$("[value='http://stackoverflow.com/questions/15513263/abc']")\[/code\] which uses the property instead of the attribute? And if not, is there a cleaner way than using the \[code\].filter(hasValue)\[/code\] and \[code\].filter(hasNoValue)\[/code\] methods?Thanks