1
4

4 に答える 4

1

次のように属性を直接取得する必要があります。

expect(myelement.getAttribute('disabled')).toBeTruthy();

分度器のテストでこれを毎日問題なく使用しています。

于 2014-12-31T18:05:22.777 に答える
0

MBielski の答えは機能しますが、 を使用するよりも少しクリーンで、 をgetAttribute()使用することになりますisEnabled()

expect(myelement.isEnabled()).toBe(false);
于 2014-12-31T19:42:14.630 に答える
-1
if (dcoument.getElementById("a").disabled) {
    //disabled
} else {
    //active
}
于 2014-12-31T17:59:57.060 に答える
-1

jQueryを使用して、リンクで属性が有効または無効になっていることを簡単に判断できますか

$(function() { $('input[type="button"]').on('click',function(){

    if($('a').prop('disabled')){ // checks whenever the element has the given atribute
    alert('it is enabled');
    } else {

    alert('it is not enabled');
    }
    });

http://jsfiddle.net/ukLsxna2/1/

于 2015-01-01T02:42:16.083 に答える