我有一个锚标记(即取消按钮),在jsp文件中有一个class属性和href属性.
我onclick在一个单独的js文件中为class属性编写了一个事件.因此,当单击该按钮时,onclick事件将执行,然后转到href链接.
当多次单击该按钮时,它会将我带到空白页面或错误页面.
我想阻止多次点击按钮.
我已经尝试event.preventdefault()在我的onclick()函数中使用函数,但如果我这样做,href链接不起作用.还有其他方法吗?
我的JS代码:
$('.cancel-btn').on('click',function(evt){
//evt.preventDefault();
//My Code
});
Run Code Online (Sandbox Code Playgroud) 我在反应文件中使用 switch 语句 .Getting Expression Expected error in first case line。
export default ({handle, state}) => (
<div style={styles.container} >
<h3 style={{margin: 0, marginBottom: 15}}>InputData</h3>
{items.map((item) => (
<div style={styles.lineContainer}>
switch(item.name){
case "name1": return <InputBox/>;
case "name2": return <SelectBox/>;
case "name3": return <<SelectBox/>;/>;
default: return <InputBox/>
}
</div>
))}
</div>
);
Run Code Online (Sandbox Code Playgroud)