简体   繁体   English

JS生成的代码可供屏幕阅读器读取

[英]JS generated code readable for screen readers

I'm trying to understand and figure out if the code generated by JavaScript will provide info for screenreaders like regular HTML tags. 我正在尝试了解并弄清楚JavaScript生成的代码是否可以为屏幕阅读器提供信息,例如常规HTML标签。 I'll show you what I mean. 我会告诉你我的意思。

I want my div1 text to change relatively. 我希望我的div1文本相对更改。

<script>
function changeText()
{
 document.getElementById('div1').innerHTML = '<input type="button" onclick="changeText2()" value="Change Text2" />';
}
function changeText2()
{
 document.getElementById('div1').innerHTML = '<input type="button" onclick="changeText()" value="Change Text" />';
}
</script>
<div id="div1">
<input type='button' onclick='changeText()' value='Change Text'/>
</div>

It does the trick and I'm very excited by that, because I'm very new to coding, but I want my site to be adoptable for blind people who use screenreaders. 它确实可以解决问题,对此我感到非常兴奋,因为我对编码非常陌生,但是我希望我的网站能够被使用屏幕阅读器的盲人所采用。 When I checked the generated HTML code, the code does not change by pressing the button, so I assume the screenreaders will be reading this first button(in the HTML layout) without paying any attention for the generated code. 当我检查生成的HTML代码时,按下按钮不会更改代码,因此我假设屏幕阅读器将在HTML布局中读取此第一个按钮,而无需关注生成的代码。

If I'm right, what can I do about it? 如果我是对的,我该怎么办? Is there any way to change text like that. 有没有办法改变这样的文字。

查看可访问的富Internet应用程序(WAI-ARIA)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM