bar*_*ala 5 html javascript jquery
我想知道我是否可以<strong>在javascript中设置文本或初始文本.
<!DOCTYPE html>
<html>
<body>
<script>
$(document).ready(function(){
// what should I do here?
}
</script>
<strong>Strong text</strong>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
非常感谢.
Roy*_*M J 11
最好将类或id添加到html元素,如下所示:
JS:
$(document).ready(function(){
$(".text").html("Your content here...");
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<strong class="text">Strong text</strong>
Run Code Online (Sandbox Code Playgroud)
演示:http://jsbin.com/cihilobe/1/
给元素一个 id,这段普通的 javascript 就可以完成这项工作。
document.getElementById("id").innerHTML = "some text";
Run Code Online (Sandbox Code Playgroud)
或者jquery
$("#id").text("some text");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18290 次 |
| 最近记录: |