jquery mobile 使用button的oncilk
时间: 2024-04-12 20:33:43 浏览: 25
在 jQuery Mobile 中,可以使用 `click` 事件来处理按钮的点击操作。下面是一个示例代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery Mobile Button Click Event</title>
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script>
$(document).on('pageinit', function() {
$('#myButton').on('click', function() {
// 在这里处理按钮的点击事件
alert('按钮被点击了!');
});
});
</script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Button Click Example</h1>
</div>
<div role="main" class="ui-content">
<a href="#" id="myButton" data-role="button">点击我</a>
</div>
</div>
</body>
</html>
```
在这个示例中,我们使用了 jQuery Mobile 的样式和脚本文件,并在页面初始化事件 `pageinit` 中绑定了按钮的 `click` 事件。当按钮被点击时,会弹出一个提示框。
你可以根据自己的需求修改按钮的样式和事件处理函数。希望这能帮到你!如果还有其他问题,请随时提问。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)