爲什麼這不是工作,我怎麼這樣做正確:焦點jQuery的
if ($('#ch03').is(':focus')) {
$('this').attr("aria-grabbed","true");
} else {
$('this').attr("aria-grabbed","false");
}
或基於現有的SO解決方案,我不能去上班
var inFocus = false;
$('#ch03').focus(function() {
$('#ch03').attr("aria-grabbed","true");
});
$('#ch03').blur(function() {
$('#ch03').attr("aria-grabbed","false");
});
HTML
<div id="activity_contents">
<div id="columns" class="clearfix">
<div id="col_1" class="column">
<div class="column_head">Section A</div>
<ul id="tier1" class="connected" role="region" aria-labelledby="col_1" aria-dropeffect="move">
</ul>
<div class="clearfix"></div>
</div>
<div id="col_2" class="column">
<div class="column_head">Section B</div>
<ul id="tier2" class="connected" role="region" aria-labelledby="col_2" aria-dropeffect="move">
</ul>
</div>
<div id="col_3" class="column">
<div class="column_head">Section C</div>
<ul id="tier3" class="connected" role="region" aria-labelledby="col_3" aria- dropeffect="move">
</ul>
</div>
<div id="col_4" class="column last">
<div class="column_head">Section D </div>
<ul id="tier4" class="connected" role="region" aria-labelledby="col_4" aria-dropeffect="move">
</ul>
</div>
</div>
<div id="well" class="clearfix">
<ul id="choices" class="connected" aria-labelledby="well" role="region">
<li id="ch01" class="choice"><a href="#">Drag item 1</a></li>
<li id="ch03" class="choice"><a href="#">Drag item 2</a></li>
<li id="ch04" class="choice"><a href="#">Drag item 3</a></li>
<li id="ch02" class="choice"><a href="#">Drag item 4</a></li>
</ul>
</div>
</div>
感謝您對此問題的任何幫助。代碼來自jQueriUI dragnDrop/Sortable。我試圖實現的是通過動態添加aria角色來使這更容易訪問。
這是指元素,沒有這樣的元素叫做'this'。刪除此處的引號 – DinoMyte
感謝DinoMyte但仍未添加重點屬性 –
什麼類型的元素是「#ch03''? 它是一個div或表單元素(文本,選擇等)。 因爲此方法適用於文本,選擇但不與div –