小编Jok*_*ean的帖子

如何防止多次单击Anchor标记按钮

我有一个锚标记(即取消按钮),在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)

javascript jquery

10
推荐指数
2
解决办法
1270
查看次数

React 中使用 Switch 语句预期的表达式

我在反应文件中使用 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)

javascript reactjs react-native

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

javascript ×2

jquery ×1

react-native ×1

reactjs ×1