例如:String[] str = {"M1","M1","M1","M2","M3"};
最推荐的是答案 - HashSet
.哪种方法还是你有更好的想法?
我想隐藏最接近点击按钮的跨度,并隐藏按钮.
html就是这样的
<!-- the div will be looped using php -->
<!-- this will only be a general idea of the code as the actual is very long and messy -->
<div>
<form><!-- This is like the head section -->
<div>
<div> <!-- some divs -->
<button class="btn"></button> <!-- where i want it to work -->
<div></div><!-- make this 5 times -->
<span>content to hide</span>
</div>
</div>
</form>
<div><!-- Comments to the head are here -->
<button class="btn"></button><!-- button where …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在选择特定字体样式时为用户创建简单的选择选项.如果他们点击字体div
,其背景div
应该改变颜色.
我遇到的问题是第一种字体div
在改变颜色时效果很好 - 但是其他字体div
并不适用.
HTML
<div class="fonts">
<div id="font" class="minecraft-evenings">
Hello
<p>Minecraft Evenings</p>
</div>
<div id="font" class="minecrafter">
Hello
<p>Minecrafter 3</p>
</div>
<div id="font" class="volter">
Hello
<p>Volter</p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
的JavaScript/JQuery的
$(document).ready(function() {
$('#font').click(function() {
$(this).css("background-color", "#000");
$('#font').not(this).css("background-color", "#f1f1f1");
});
});
Run Code Online (Sandbox Code Playgroud) 我在我的网站上使用第三方聊天插件,我只是将其javascript代码放在我的网站上。代码是:
<script type="text/javascript">
var __lc = {};
__lc.license = 1812482;
(function() {
var lc = document.createElement('script'); lc.type = 'text/javascript'; lc.async = true;
lc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.livechatinc.com/tracking.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(lc, s);
})();
</script>
Run Code Online (Sandbox Code Playgroud)
现在我的网站上有一张图片,我希望有人单击该图片然后打开聊天窗口。如何通过单击该图像来调用此函数。
<img src="click_to_chat.png" onclick=""/>
Run Code Online (Sandbox Code Playgroud)