<div class="check">
<div class="mui-input-row mui-checkbox ">
<label>Java从入门到精通</label>
<input name="books" type="checkbox" value="java" >
</div>
<div class="mui-input-row mui-checkbox ">
<label>剑指offer</label>
<input name="books" type="checkbox" value="offer">
</div>
<div class="mui-input-row mui-checkbox ">
<label>Python从入门到精通</label>
<input name="books" type="checkbox" value="python">
</div>
</div>
<div class="save">
<button type="button" class="mui-btn mui-btn-blue mui-btn-outlined" id="getBooks">抢购</button>
</div>
微信公众号:JavaWeb架构师
微信公众号:JavaWeb架构师
var books = document.getElementsByName("books");
document.getElementById('getBooks').addEventListener('tap', function() {
var result = "您已抢到:";
for(var i = 0; i < books.length; i++) {
if(books[i].checked) {
result += books[i].value + "、"
}
}
mui.toast(result + (++index))
})
// 模拟用户选择
$(books).trigger("click")
var btn = document.getElementById("getBooks");
// 通过定时器不断的抢
setInterval(function() {
mui.trigger(btn,"tap")
},500)
微信公众号:JavaWeb架构师
微信公众号:JavaWeb架构师
微信公众号:JavaWeb架构师
微信公众号:JavaWeb架构师
- 编写js框架
javascript: void (
(function () {
// 脚本内容
})());
- 填充脚本内容
javascript: void (
(function () {
var books = document.getElementsByName("books");
$(books).trigger("click");
var btn = document.getElementById("getBooks");
setInterval(function() {
mui.trigger(btn,"tap");
},500);
})());
-
新建书签,内容是上面的脚本内容
微信公众号:JavaWeb架构师
- 打开页面
- 再打开刚刚咱们用脚本新建的书签
源码下载
关注下方的微信公众号,回复:js_books.code
网友评论