close
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<style type="text/css">
li{
width: 300px;
padding: 20px;
background-color: #eee;
list-style: none;
margin: 10px;
}
</style>
</head>
<body>
<ul>
<li class="one"><span>1</span></li>
<li class="two">2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
<script type="text/javascript">
$('li').filter(':last').css('background-color','#00f');
$('li').each(function(){
$(this).has('span').css('background-color','#0f0');
/*不會傳回布林值*/
if($(this).is('.two')){
$(this).css('background-color','#f00');
}
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
<input type="text" name="" id="input">
<script type="text/javascript">
$('#input').after('<h2>這個輸入框的type是text嗎:'+$('#input').is(':text')+'</h2>');
</script>
</body>
</html>
全站熱搜
留言列表