「jQuery入門.next([selector])のサンプル

2021年2月19日

書式
$(セレクタ名).next(クラス名).css(xxx)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>next demo</title>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<p>Study skill </p>
<p class="cft">in argame</p>
<p>one 111</p>
<div><span>test123456</span></div>
<script>
$( "p" ).next( ".cft" ).css( "background", "red" );
</script>
</body>
</html>
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>next demo</title> <script src="https://code.jquery.com/jquery-3.5.0.js"></script> </head> <body> <p>Study skill </p> <p class="cft">in argame</p> <p>one 111</p> <div><span>test123456</span></div> <script> $( "p" ).next( ".cft" ).css( "background", "red" ); </script> </body> </html>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>next demo</title>
  <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<p>Study skill </p>
<p class="cft">in argame</p>
<p>one 111</p>
<div><span>test123456</span></div>

<script>
$( "p" ).next( ".cft" ).css( "background", "red" );
</script>
 
</body>
</html>

 

jQuery

Posted by arkgame