調べながら追加したのですが書き換えができず、scriptタグ「src」の書き換えについてお教えいただけると助かります
どうぞよろしくお願い致します。
前提・実現したいこと
html内の「<script language='javascript' src='test.js' class="time"></script>」部分の「src='test.js'」にページを開いた時間を付与したい
例:2018年11月6日11時4分にページを開いた場合↓↓
src='testjs&time=2018116114'
html
1<!doctype html> 2<html> 3<head> 4<meta charset="utf-8"> 5<title>無題ドキュメント</title> 6<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script> 7<script language='javascript' src='test.js' class="time"></script> 8 <script> 9$(function(){ 10 11$(".time").each(function() { 12var now = new Date(); 13var now = new Date(); 14var y = now.getFullYear(); 15var m = now.getMonth() + 1; 16var d = now.getDate(); 17var w = now.getDay(); 18var h = now.getHours(); 19var mi = now.getMinutes(); 20var s = now.getSeconds(); 21var obj = jQuery(this); 22 var link = obj.attr("src"); 23 obj.attr("src",link+"&time="+y + m + d + h + mi); 24}); 25 26}); 27</script> 28</head> 29<body> 30</body> 31</html>
回答2件
あなたの回答
tips
プレビュー