@zizou10235

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

このセレクタの意味が知りたいです

解決したいこと

ここに解決したい内容を記載してください。
let current = 1;
$("#slide li:nth-child(" + current + ")").メソッド

上記の(" + current + ")という表記の仕方。特に+で囲うというのがどういう意味か教えていただきたいです。

0 likes

1Answer

+は文字列結合です。

let current = 1;
$("#slide li:nth-child(" + current + ")")
// ↓
$("#slide li:nth-child(" + 1 + ")")
// ↓暗黙の型変換
$("#slide li:nth-child(1)")

// 以下の書き方もできます
$(`#slide li:nth-child(${current})`)
1Like

Comments

  1. @zizou10235

    Questioner

    ありがとうございます。解決できました。

Your answer might help someone💌