触发容器onclick(Trigger container onclick)
我需要重写以下代码,以便当您单击“next”按钮或其他内容时,将打开下一个容器并关闭当前容器。 同样的事情是按钮“返回”。
不幸的是,我不知道如何重写代码来获得想要的结果,因为我的偏好在后端最多,我仍然是JavaScript和jQuery的新手。
这是我现在的代码:
$(document).ready(function() { $('.trigger').not('.trigger_active').next('.toggle_container').hide(); $('.trigger').click(function() { var trig = $(this); if(trig.hasClass('trigger_active')) { trig.next('.toggle_container').slideToggle(500); trig.removeClass('trigger_active'); } else { $('.trigger_active').next('.toggle_container').slideToggle(500); $('.trigger_active').removeClass('trigger_active'); trig.next('.toggle_container').slideToggle(500); trig.addClass('trigger_active'); }; return false; }); });
和班级:
<div class="trigger"> <table width="385px" cellspacing="5px" style="border: 1px solid #FFFFFF;"> <tr> <th align="left">User Information</th> <th align="right"><font size="1">(click to expand)</font></th> </tr> </table> </div> <div class="toggle_container"> <table width="385px" cellspacing="5px" style="border-left: 1px solid #FFFFFF; border-top: 0; border-right: 1px solid #FFFFFF; border-bottom: 1px solid #FFFFFF;"> <tr> <td align="left">Username<font color="#8E6516">*</font></td> <td align="right"><input name="username" id="username" type="text" style="background: transparent; background-color: #FFFFFF; color: #8E6516; width: 135px;" placeholder="Benutzername" required="required" /></td> </tr> <tr> <td align="left">Password<font color="#8E6516">*</font></td> <td align="right"><input name="password" id="password" type="password" style="background: transparent; background-color: #FFFFFF; color: #8E6516; width: 135px;" placeholder="Mindestens 6 Zeichen" required="required" /></td> </tr> <tr> <td align="left">Password<font color="#8E6516">*</font></td> <td align="right"><input name="confirmpwd" id="confirmpwd" type="password" style="background: transparent; background-color: #FFFFFF; color: #8E6516; width: 135px;" placeholder="Passwort wiederholen" required="required" /></td> </tr> <tr> <td align="left">E-Mail<font color="#8E6516">*</font></td> <td align="right"><input name="email" id="email" type="text" style="background: transparent; background-color: #FFFFFF; color: #8E6516; width: 135px;" placeholder="E-Mail Adresse" required="required" /></td> </tr> <tr> <td align="left"><input name="back" type="button" value="Back" style="background: transparent; border-color: #8E6516; color: #FFFFFF; width: 135px;" /></td> <td align="right"><input type="button" name="next" value="Next" style="background: transparent; background-color: #FFFFFF; color: #8E6516; width: 135px;" /></td> </tr> </table> </div>
I need to rewrite the following code so that when you click on button "next" or something, the next container opens and the current one closes. The same thing goes for the button "back".
Unfortunately I don't know exactly how to rewrite the code to get the wanted result, because my preferences lie the most in backend and I'm still pretty new to JavaScript and jQuery.
Here's my current code:
$(document).ready(function() { $('.trigger').not('.trigger_active').next('.toggle_container').hide(); $('.trigger').click(function() { var trig = $(this); if(trig.hasClass('trigger_active')) { trig.next('.toggle_container').slideToggle(500); trig.removeClass('trigger_active'); } else { $('.trigger_active').next('.toggle_container').slideToggle(500); $('.trigger_active').removeClass('trigger_active'); trig.next('.toggle_container').slideToggle(500); trig.addClass('trigger_active'); }; return false; }); });
And the class:
<div class="trigger"> <table width="385px" cellspacing="5px" style="border: 1px solid #FFFFFF;"> <tr> <th align="left">User Information</th> <th align="right"><font size="1">(click to expand)</font></th> </tr> </table> </div> <div class="toggle_container"> <table width="385px" cellspacing="5px" style="border-left: 1px solid #FFFFFF; border-top: 0; border-right: 1px solid #FFFFFF; border-bottom: 1px solid #FFFFFF;"> <tr> <td align="left">Username<font color="#8E6516">*</font></td> <td align="right"><input name="username" id="username" type="text" style="background: transparent; background-color: #FFFFFF; color: #8E6516; width: 135px;" placeholder="Benutzername" required="required" /></td> </tr> <tr> <td align="left">Password<font color="#8E6516">*</font></td> <td align="right"><input name="password" id="password" type="password" style="background: transparent; background-color: #FFFFFF; color: #8E6516; width: 135px;" placeholder="Mindestens 6 Zeichen" required="required" /></td> </tr> <tr> <td align="left">Password<font color="#8E6516">*</font></td> <td align="right"><input name="confirmpwd" id="confirmpwd" type="password" style="background: transparent; background-color: #FFFFFF; color: #8E6516; width: 135px;" placeholder="Passwort wiederholen" required="required" /></td> </tr> <tr> <td align="left">E-Mail<font color="#8E6516">*</font></td> <td align="right"><input name="email" id="email" type="text" style="background: transparent; background-color: #FFFFFF; color: #8E6516; width: 135px;" placeholder="E-Mail Adresse" required="required" /></td> </tr> <tr> <td align="left"><input name="back" type="button" value="Back" style="background: transparent; border-color: #8E6516; color: #FFFFFF; width: 135px;" /></td> <td align="right"><input type="button" name="next" value="Next" style="background: transparent; background-color: #FFFFFF; color: #8E6516; width: 135px;" /></td> </tr> </table> </div>
原文:https://stackoverflow.com/questions/40320411
最满意答案
这将从搜索结果中排除名称在exclude_dirs_list中的所有目录。 实际上,名称不是完整路径,因此不仅会排除/ a / b / c / dir1,还会排除/ a / b / c / d / e / dir1。
proc rglob { dirpath exclude_dirs_list} { set rlist "" foreach fpath [glob -nocomplain -tails -types f -directory ${dirpath} *] { lappend rlist [file join ${dirpath} ${fpath}] } foreach dir [glob -nocomplain -tails -types d -directory ${dirpath} *] { if {[lsearch -exact $exclude_dirs_list $dir] == -1} { lappend rlist {*}[rglob [file join ${dirpath} ${dir}] $exclude_dirs_list] } } return ${rlist} } rglob /a/b/c [list dir1 dir2]
如果您只需要排除/ a / b / c / dir1,您应该更改
lappend rlist {*}[rglob [file join ${dirpath} ${dir}] $exclude_dirs_list]
至
lappend rlist {*}[rglob [file join ${dirpath} ${dir}] {}]
This will exclude from search resuls all directories with names in exclude_dirs_list. In fact, names are not full paths, so not only /a/b/c/dir1 will be excluded, but /a/b/c/d/e/dir1 too.
proc rglob { dirpath exclude_dirs_list} { set rlist "" foreach fpath [glob -nocomplain -tails -types f -directory ${dirpath} *] { lappend rlist [file join ${dirpath} ${fpath}] } foreach dir [glob -nocomplain -tails -types d -directory ${dirpath} *] { if {[lsearch -exact $exclude_dirs_list $dir] == -1} { lappend rlist {*}[rglob [file join ${dirpath} ${dir}] $exclude_dirs_list] } } return ${rlist} } rglob /a/b/c [list dir1 dir2]
If you need to exclude only /a/b/c/dir1 you should change from
lappend rlist {*}[rglob [file join ${dirpath} ${dir}] $exclude_dirs_list]
to
lappend rlist {*}[rglob [file join ${dirpath} ${dir}] {}]
相关问答
更多-
Tcl:删除目录 - 如何忽略无法删除的文件(Tcl: Directory deletion - how to ignore files that cannot be deleted)[2023-11-11]
您可以将file delete包装在一个catch语句中: catch { file delete -force -- $env(TMP) } 我希望你永远不要以root身份运行。 删除你的/ tmp目录将是一件坏事。 参考文献: catch You can wrap the file delete in a catch statement: catch { file delete -force -- $env(TMP) } I hope you never run this as root. Dele ... -
例如,如果要排除misc目录,只需将-path ./misc -prune -o添加到find命令中: find . -path ./misc -prune -o -name '*.txt' -print 这是一个有多个目录的例子: find . -type d \( -path dir1 -o -path dir2 -o -path dir3 \) -prune -o -print 这里我们排除dir1,dir2和dir3,因为在find表达式中,它是一个动作,它作用于条件-path dir1 -o ...
-
如何在find中排除目录(how to exclude a directory in find)[2022-05-25]
find * -path "backoffice/target/" -prune -o -type f \( -name "*.groovy" -o -name "*.gsp" \) -print find * -path "backoffice/target/" -prune -o -type f \( -name "*.groovy" -o -name "*.gsp" \) -print -
尽管将某些参数传递给CSC.exe以排除/recurse开关中的某些文件会很好。 我没有在任何地方找到它。 我选择的解决方案是: 将每个Visual Studio项目的所有源文件复制到不同的文件夹,不包括AssemblyInfo.cs文件。 编译该文件夹中的所有文件以生成.netmodule. Although it would be nice to pass some parameter to CSC.exe to exclude some files from /recurse switch. I di ...
-
无法从特定目录中排除SonarQube中的项目(Unable to exclude projects in SonarQube from a specific directory)[2022-07-28]
.Targets似乎并不总是删除,对于我想要排除的项目,在.sonarqube目录中列出了IsExcluded。 似乎比修改我的所有项目更少的工作。 .Targets doesn't appear to always remove, powershell'ed the IsExcluded in the .sonarqube directory for the projects I wanted to exclude. Seems like less work than modifying all my p ... -
Tcllib有一个fileutil模块,可以执行递归查找: package require fileutil set filenames [::fileutil::findByPattern /dir -glob {*.so *.a}] foreach filename $filenames { if {[file isfile $filename]} { set dirs([file dirname $filename]) 1 } } puts [array names d ...
-
rsync手册说 INCLUDE/EXCLUDE PATTERN RULES ... o use ’**’ to match anything, including slashes. 所以你可以做到 rsync -a --exclude='Folder2/**.tar' Source/ Target 请注意,这与bash的globstar选项不同,您可以使用Folder/**/*.tar 。 rsync manual says INCLUDE/EXCLUDE PATTERN RU ...
-
如何在tcl中排除该目录下的特定目录和所有文件(How to exclude particular directory and all files under that directory in tcl)[2023-08-08]
这将从搜索结果中排除名称在exclude_dirs_list中的所有目录。 实际上,名称不是完整路径,因此不仅会排除/ a / b / c / dir1,还会排除/ a / b / c / d / e / dir1。 proc rglob { dirpath exclude_dirs_list} { set rlist "" foreach fpath [glob -nocomplain -tails -types f -directory ${dirpath} *] { ... -
如何在目录中复制文件而不是TCL中的整个目录?(How to copy files within directory rather than a whole directory in TCL?)[2022-07-20]
使用glob命令枚举源目录下的条目并分别复制它们: foreach f [glob -directory $sourceDir -nocomplain *] { file copy -force $f $targetDir } Use the glob command to enumerate the entries under the source directory and copy each of them separately: foreach f [glob -directory $so ... -
通配符可用于对目录中的多个文件强制执行操作。 看到这个: - packagingOptions { exclude 'org/apache/commons/codec/language/bm/*' } 您也可以通过这种方式排除文件/目录而不指定完整路径: - packagingOptions { exclude '**/language/bm/*' } 注意:这将排除路径中的任何language/bm/ any wild card can be used to enforce action t ...