|
<div id="listak">
<ul>
- <li>
<span class="cls"> span elem </span>
</li>
- <li>
<span> span elem <span> span elem <span id="spn"> span elem </span></span></span>
</li>
- <li>
<ol>
- <li class="cls">
<span> span elem </span>
</li>
</ol>
</li>
</ul>
<ol>
- <li>
<span class="cls"> span elem </span>
</li>
- <li>
<span class="cls"> span elem </span>
<span> span elem </span>
</li>
</ol>
</div>
|
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#find").click(function(event){
$("ul").find("li").css({"border": "3px solid red", "background-color": "orange"});
});
$("#find02").click(function(event){
$("li").find("span").css({"border": "3px solid red", "background-color": "orange"});
});
$("#find03").click(function(event){
$("ul").find("span").css({"border": "3px solid red", "background-color": "orange"});
});
$("#find04").click(function(event){
$("ol").find("span").css({"border": "3px solid red", "background-color": "orange"});
});
$("#find05").click(function(event){
$("#listak").find("span").css({"border": "3px solid red", "background-color": "orange"});
});
$("#find06").click(function(event){
$("#listak").find("ul,ol").css({"border": "3px solid red", "background-color": "orange"});
});
$("#find07").click(function(event){ $("#listak").find("ul,ol,span")
.css({"border": "3px solid red", "background-color": "orange"});
});
$("#find08").click(function(event){
$("#listak").find(".cls").css({"border": "3px solid red", "background-color": "orange"});
});
$("#find09").click(function(event){
$("ul ol").find(".cls").css({"border": "3px solid red", "background-color": "orange"});
});
$("#find10").click(function(event){
$("#listak").find("#spn").css({"border": "3px solid red", "background-color": "orange"});
});
// Szelektorral kiválasztott leszármazott elem, változóhoz rendelése. ---------
$("#valtozohoz").click(function(event){
var $leszarmazott = $("span");
$("ul").find($leszarmazott).css({"color": "black", "border": "3px solid red", "background-color": "orange"});
});
});
</script>
</head>
<body>
<div id="listak">
<ul>
<li> <span class="cls"> span elem </span> </li>
<li> <span> span elem
<span> span elem
<span id="spn"> span elem </span>
</span> </span>
</li>
<li>
<ol> <li class="cls"> <span> span elem </span> </li> </ol>
</li>
</ul>
<ol>
<li> <span class="cls"> span elem </span> </li>
</ol>
</div>
<button id="find">ul elemben lévő, li elemek. </button>
<button id="find02">li elemben lévő, span elemek. </button>
<button id="find03">ul elemben lévő, span elemek. </button>
<button id="find04">ol elemben lévő, span elemek. </button>
<button id="find05">id="listak" elemben lévő, span elemek. </button>
<button id="find06">id="listak" elemben lévő, ul és ol elemek. </button>
<button id="find07">id="listak" elemben lévő, ul, ol és span elemek. </button>
<button id="find08">id="listak" elemben lévő, class="cls" elemek. </button>
<button id="find09">ul területén, ol elemben lévő, class="cls" elemek. </button>
<button id="find10">id="listak" elemben lévő, id="spn" elem. </button>
<button id="valtozohoz">Változóhoz rendelés.<br /> var $leszarmazott = $("span"); <br />Kattints ide!</button>
</body>
|