文字列の操作:

文字列を指定してCopyrightを生成

名称以降の文字列を指定してCopyrightの文字列を生成して、id値で指定したNodeに差し込む。
自動的に、指定した年〜今年の表記となるので、年が変わってもHTMLコードを更新する必要はない。

String1
差し込み先のid値を指定
Number
開始年(西暦)を数値で渡す
●0にすると、開始年は表示せずに現在の年だけを表示する。 ●マイナス値を指定すると、年表示を省略する。
String2
企業名などの名称以降の文字列を渡す
●必須引数 ●オプション引数(省略可能)

記述例

$setRightsWithTxt('copyright', 2000, 'The Name. Repost is prohibited.')
$setRightsWithTxt('copyright', 0, 'The Name. Repost is prohibited.')
$setRightsWithTxt('copyright', -1, 'The Name. Repost is prohibited.')
$setRightsWithTxt('copyright', 2023, 'The Name. Repost is prohibited.')

動作サンプル

Copyrightを生成して出力する。

id="sample1"
HTML : <div id="sample1"></div>
Javascript : $setRightsWithTxt('sample1',2000,'The Corporation. Repost is prohibited.');

年表示省略のCopyrightを生成して出力する。

id="sample2"
HTML : <div id="sample2"></div>
Javascript : $setRightsWithTxt('sample2',-1,'The Corporation. Repost is prohibited.');
※上記のサンプルコードは主にPC表示用を想定している。スマホ用のコーディングでは別途調整が必要となる可能性がある。
※この関数の動作サンプルとして必須ではない装飾的なCSSコードなどは省略して提示している。