实际上,我正在尝试在日期更改时更改DIV内容。
我可以通过动画功能()更改Div内容。
但我无法将其应用为日期更改... T.T
这是我的代码。
src\deck.rs:85:9: 85:19 error: cannot borrow `self.cards` as mutable because it is also borrowed as immutable [E0502]
src\deck.rs:85 self.cards.clear();
^~~~~~~~~~
src\deck.rs:75:15: 75:25 note: previous borrow of `self.cards` occurs here; the immutable borrow prevents subsequent moves or mutable borrows of `self.cards` until the borrow ends
src\deck.rs:75 for card in self.cards.iter() {
^~~~~~~~~~
src\deck.rs:92:6: 92:6 note: previous borrow ends here
src\deck.rs:68 pub fn shuffle(&mut self) {
...
src\deck.rs:92 }
^
src\deck.rs:90:13: 90:23 error: cannot borrow `self.cards` as mutable because it is also borrowed as immutable [E0502]
src\deck.rs:90 self.cards.push(*card)
^~~~~~~~~~
src\deck.rs:75:15: 75:25 note: previous borrow of `self.cards` occurs here; the immutable borrow prevent
s subsequent moves or mutable borrows of `self.cards` until the borrow ends
src\deck.rs:75 for card in self.cards.iter() {
^~~~~~~~~~
src\deck.rs:92:6: 92:6 note: previous borrow ends here
src\deck.rs:68 pub fn shuffle(&mut self) {
...
src\deck.rs:92 }
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<script src="js/jquery-1.12.2.min.js"></script>
<style>
.stick{
background :cyan;
width:0px; height:20px
}
答案 0 :(得分:1)
尝试使用它:
HTML:
<input type="date" name="date" id="date"/>
<div class="stick"></div>
JS:
var d = $('#date').change(function(){
$(".stick").animate({width:"+=10"});
});
CSS:
.stick{
background :cyan; width:0px; height:20px
}
Jsfiddle: https://jsfiddle.net/w5ur8w2u/
答案 1 :(得分:0)
如果您正在关注的内容类似于数字时钟,那么您可能需要setInterval
。