我讀jQuery的使用(「*」),我不知道爲什麼使用("*")
請解釋它有助於什麼是jQuery的
<script>
$(document).ready(function(){
$("button").click(function(){
$("*").hide();
});
});
</script>
我讀jQuery的使用(「*」),我不知道爲什麼使用("*")
請解釋它有助於什麼是jQuery的
<script>
$(document).ready(function(){
$("button").click(function(){
$("*").hide();
});
});
</script>
$(*)
用來選擇文檔中的所有元素。請參閱此:https://www.w3schools.com/jquery/sel_all.asp
$(*)
是jqueryto一個選擇器中選擇的所有元素
,因此
$("*").hide();
會隱藏所有元素
$(document).ready(function(){
$("button").click(function(){
$("*").hide();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>Hello</div>
<p>World</p>
<span>Good Morning</span>
<button>Hide</button>
*
是jquery中的一個選擇器,它可以在沒有任何條件(包括html,head和body)的情況下選擇所有內容。
以下是解釋其用法的示例。
$(document).ready(function(){
$("button").click(function(){
$("*").hide();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
Hello text
</div>
<button>Click Me to Hide everything</button>
$(document).ready(function(){
$("button").click(function(){
$("div *").toggle();
});
});
div{
border:0.5px solid red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<p>Hello text</p>
<a>Here is a link </a>
</div>
<button>Click Me to Hide/ Show elements inside the div</button>
請參考選擇器計算器文件建立http://stackoverflow.com/documentation/jquery/389/selectors/4136/overview#t=2017040107020653041並請提問前請參考文檔像這樣的問題。 – Lucky
爲什麼你爲這個問題標記Java? –