每次悬停输入框时,我都试图让图标更改颜色。问题是它只在悬停第一个输入文本框时更改背景,而不是其他两个。
我正在尝试在没有 jquery 的情况下获得这种效果。提前感谢您的帮助!
var input = document.querySelector ('input');
var icon = document.querySelector ('img');
input.addEventListener ('mouseover', function hover(){
icon.style.background = '#D46855';
});
input.addEventListener ('mouseleave', function leave(){
icon.style.background = '#81D455';
});Run Code Online (Sandbox Code Playgroud)
@import url('https://fonts.googleapis.com/css?family=Indie+Flower');
body{
background-image :url(https://mir-s3-cdn-cf.behance.net/project_modules/max_1200/b0e53331516629.565449774c2d4.png);
}
h1{
font-family: 'Indie Flower', cursive;
font-size:3em;
color:#D46855;
letter-spacing:5px;
}
#container{
text-align:center;
margin:10% auto;
padding-top: 50px;
border-radius:15%;
width:80%;
height:400px;
position:relative;
background-color : rgba(84, 193, 212, 0.56);
box-shadow: 5px 5px 4px 5px rgba(84, 193, 212, 0.56);
}
img{
left: 0;
right: 0;
bottom: 0;
margin: auto; …Run Code Online (Sandbox Code Playgroud)我正在尝试创建一个步进器,其中数字在长按手势时快速增加,并在用户释放时停止。
到目前为止,我已经在长按上获得了增量,但是当我释放计时器时,计时器仍然继续,继续增加状态。
我该如何解决当用户松开按键时计时器停止的问题。
struct CustomFoodItemView: View {
@State var foodName = ""
@State var proteinAmount = 1
@State var carbAmount = 1
@State var fatAmount = 1
@State private var timer: Timer?
@State var isLongPressing = false
var body: some View {
VStack{
VStack{
Text("Food Name")
TextField("", text: $foodName)
.multilineTextAlignment(.center)
.border(.white)
.padding(.trailing, 10)
.frame(width:100, height:10)
}
HStack{
Text(String(proteinAmount) + "g")
.frame(width:50, height:50)
Image(systemName: "plus.circle.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 30, height: 30)
.foregroundColor(Color("SuccessButtonColor"))
.simultaneousGesture(LongPressGesture(minimumDuration: 0.2).onChanged { _ in
print("long press")
self.isLongPressing …Run Code Online (Sandbox Code Playgroud) 在JavaScript中引发了一个问题并遇到了一些让我感兴趣的东西.我开始出现一个问题,只需要将数字1-100打印到屏幕上.然后我在开始时看到我for loop生成了一个空列表元素.
很好奇为什么会这样.
//VARIABLES
let list = document.querySelector('ul');
//PRINT NUMBERS 1 - 100 TO THE SCREEN
for(i = 1; i <= 100; i++){
let li = document.createElement('li');
li.innerHTML = [i];
list.appendChild(li);
}Run Code Online (Sandbox Code Playgroud)
<div class = "container_list">
<ul>
<li></li>
</ul>
</div>Run Code Online (Sandbox Code Playgroud)
如果我有这样的javascript对象:
sampleObject[
{
suite: "Clubs",
weight : 10
},
{
suite: "Spades",
weight : 6
},
{
suite: "Hearts",
weight : 2
}
];
Run Code Online (Sandbox Code Playgroud)
我如何找到重量属性的总和?