Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
img-1、img-2 などの名前の画像があります。部分文字列を作成し、num をインクリメントしてから、すべての画像をループしたいのですが、どうすれば達成できますか。jQuery を使用します。
この場合Substringは使用しないと思いますsplit
Substring
split
var splitter= imgName.split('-'); var numberString = splitter[1]; //gives second part .i.e number var integerNum =parseInt(numberString); //here numberString converts to integer integerNum++; // increment
上記のコードをループに入れて使用します。