如何给span标签赋值,javascript_span赋值,js给span标签赋值js给span标签赋值的方法?一般有两种方法: 第一种方法:输出html <body onload="s()"><span id="hello"></span><script language="javascript"> function s(){document.getElementById("hello").innerHTML = "<iframe src= height=400 width=300></iframe>";} </script> 第二种方法:输出文本 <body onload="s()"><span id="hello"></span><script language="javascript"> function s(){document.getElementById("hello").innerText = "hello world";}</script> 在页面加载完成后通过jquery给多个span赋值 由于我想在页面加载完成后,有几个地方显示当前时间,所以我需要给多个span赋值。 span代码的写法如下: <span name="currentDate"></span> (多个span) jQuery写法: <script> $(document).ready(function() { var currentDate = new Date().toLocaleDateString(); $("span[name='currentDate']").each(function() { $(this).text(currentDate); }); }); </script> 如何给span标签赋值,javascript_span赋值,js给span标签赋值
|