简体   繁体   English

如何暂时禁用JavaScript事件

[英]How to disable javascript events temporarily

I'm creating an accessible website for disabled students using access technologies to answer a survey. 我正在使用访问技术为问卷调查的残障学生创建一个可访问的网站。 As such it needs a lot of visual feedback. 因此,它需要大量的视觉反馈。

I use javascript to change css styles of an imagelink (that's used to select a radio button.) When the image link has focus it changes styles - however once the image is clicked (therefore clicking the radio button) I'd like it to change to a 3rd style and stay like that until another button is clicked. 我使用javascript更改了图像链接的CSS样式(用于选择单选按钮。)当图像链接具有焦点时,它会更改样式-但是,一旦单击图像(因此单击了单选按钮),我希望它进行更改保留为第3种样式,直到点击另一个按钮为止。 Currently the mouseout and onblur events stay active and revert back to the unfocused style. 当前,mouseout和onblur事件保持活动状态并恢复为未聚焦的样式。

All code is on this fiddle: http://jsfiddle.net/KK4xe/2/ 所有代码都在这个小提琴上: http : //jsfiddle.net/KK4xe/2/

I've tried: if statements for when the radio is selected and rewriting div contents onclick so that the 我已经尝试过:如果选择了何时选择收音机的语句并重写onclick的div内容,以便

Many thanks, Mike 非常感谢,迈克

(note. the radio button will be hidden with CSS once sorted so that it doesn't interfere with screen readers etc.) (请注意,单选按钮在排序后将被CSS隐藏,以免干扰屏幕阅读器等。)

Try this ; 尝试这个 ;

function changeClass1(){
--> if(!document.getElementById("YES").checked){
        document.getElementById("1").setAttribute("class", "optionfocus");
    }
}

function changeClassBack1(){
--> if(!document.getElementById("YES").checked){
        document.getElementById("1").setAttribute("class", "option");
    }
}

see example 看例子

Note: * i also added the hidden attribute for the check box (to ensure it work when hidden) 注意:*我还为复选框添加了hidden属性(以确保它在隐藏时起作用)

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

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