标签:codecombat 极客 hide showButton hideButton show image var 战记
(点击图片进入关卡)使元素消失和出现!惊吓你的敌人,迷惑你的朋友。
简介
show() 和 hide() 这两个jQuery函数分别让元素出现和消失。
默认代码
<!-- JavaScript可以用来显示和隐藏元素! --><script> var showButton = $("#showButton"); // 创建变量'hideButton'来存储#hideButton
var image = $("#image"); function showElement() { image.show(); } function hideElement() { // 在图像变量上使用“hide()”函数:
} showButton.on("click", showElement); // 添加一个事件监听器到hideButton变量。 // 当“点击”发生时,它应该执行HielEng:
</script> <style> body { text-align:center; } button { width:25%; height:64px; } img { width:50%; } </style> <button id="showButton">显示</button> <button id="hideButton">隐藏</button> <br> <img id="image" src="http://direct.codecombat.com/file/db/thang.type /57586f0a22179b2800efda37/portrait.png"/>
概览
#隐藏并显示
在元素上调用 hide() 会使元素从屏幕上消失!
与此相反, show() 则会让元素按照隐藏前的样子重新出现。 (除非在隐藏时进行过更改!)
挂接到 "click" 事件则可以为需要的隐藏和显示行为编写强大的脚本!
消失活动 解法
<!-- JavaScript可以用来显示和隐藏元素! --><script> var showButton = $("#showButton"); // 创建变量'hideButton'来存储#hideButton var hideButton = $("#hideButton"); var image = $("#image"); function showElement() { image.show(); } function hideElement() { // 在图像变量上使用“hide()”函数: image.hide() } showButton.on("click", showElement); // 添加一个事件监听器到hideButton变量。 // 当“点击”发生时,它应该执行HielEng: hideButton.on("click", hideElement); </script> <style> body { text-align:center; } button { width:25%; height:64px; } img { width:50%; } </style> <button id="showButton">显示</button> <button id="hideButton">隐藏</button> <br> <img id="image" src="http://direct.codecombat.com/file/db/thang.type /57586f0a22179b2800efda37/portrait.png"/>
本攻略发于极客战记官方教学栏目,原文地址为:
https://codecombat.163.com/news/jikezhanji-xiaoshihuodong
标签:codecombat,极客,hide,showButton,hideButton,show,image,var,战记 来源: https://www.cnblogs.com/codecombat/p/12918831.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。