jasmine-jquery toBeDisabled not working
-
09-12-2019 - |
Question
I have got following html
<a disabled="disabled"><img alt="First" src="/Content/Images/Grid/disabledFirst.png"></a>
And I run following expect
on this html
expect($(element)).toBeDisabled()
where element
is the selector for above html. The expect
fails. Further investigation lead to following code in jasmine-jquery-1.3.1.js
toBeDisabled: function(selector){
return this.actual.is(':disabled');
},
which for some reason is returning false. I'm sure I'm missing something very basic here but just not able to spot it.
Solution
This fiddle shows that jQuery only finds inputs not anchors when using :disabled
. It's understandable because the anchor element doesn't have the disabled
property
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow