给页面的一个按钮元素添加点击事件,但点击按钮却没反应
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<script src="js/mui.min.js"></script>
<link href="css/mui.min.css" rel="stylesheet"/>
<script type="text/javascript" charset="utf-8">
mui.init();
document.getElementById("asd").addEventListener('tap',function(){
alert('sdfs');
});
</script>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">标题</h1>
</header>
<div class="mui-content">
<button class="mui-btn" id="asd">按钮</button>
</div>
</body>
</html>
2 个回复
DCloud_UNI_FXY
贴代码
DCloud_heavensoft
你至少需要在mui的ready后再注册mui的专用事件,这么早注册,dom也没ready,mui也没ready,js肯定失效。
菜鸟的老大 (作者)
呵呵,已经解决了
2015-04-11 22:54