我有一个DIV,当点击时会展开以显示一些输入和按钮,并在再次点击时关闭,隐藏这些元素。我遇到的问题是当我点击按钮或输入框时,无论如何都会关闭动画。我知道我可以通过从DIV中取出输入和按钮来解决这个问题,但DIV对于它们的格式和组织非常重要。任何帮助都会很棒,谢谢!
HTML:
set.seed(1234567)
data(iris)
iris$random <- rnorm(nrow(iris), 0, 1)
log.vars <- function(dset, vars, byvar, verbose = F){
# a loop by levels of "byvar"
for(i in 1:length(unique(dset[[byvar]]))){
if(verbose == T){
print(paste0("------ level=", unique(dset[[byvar]])[i], "----"))
}
# a loop by variables in "vars"
for(j in 1:length(vars)){
min.var <- min(dset[[vars[j]]][dset[[byvar]] == unique(dset[[byvar]])[i]])
# if minimum of a given variable for a given level is greater than 0 then
# calculate its logarithm;
# otherwise, add to its value 1 and the mode of its minimum and calculate
# its logarithm
dset[[paste0("ln_", vars[j])]][dset[[byvar]] == unique(dset[[byvar]])[i]] <-
if(min.var > 0){
log(dset[[vars[j]]][dset[[byvar]] == unique(dset[[byvar]])[i]])
} else{
log(dset[[vars[j]]][dset[[byvar]] == unique(dset[[byvar]])[i]] + 1 +
abs(min.var))
}
}
}
return(dset)
}
iris2 <- log.vars(dset = iris,
vars = c("Sepal.Length", "random", "Sepal.Width"),
byvar = "Species",
verbose = T)
head(iris2)
JS:
<div id='inputArea1' class='inputAreas'>
<input id='email' class='evInput' placeholder='example@gmail.com'>
<input id='comf' class='evInput' placeholder='Comfirmation Code'>
<button id='sndCde' class='evBut'>Send Code</button>
<button id='comfBut' class='evBut'>Comfirm</button>
</div>
答案 0 :(得分:3)
event.stopPropagation();
可以完成这项工作:
$('#inputArea1').click(function(event){
event.stopPropagation();
});