<!DOCTYPE html>
<html>
<head>
<script language="javascript" type="text/javascript">
function changeValue()
{
var list, index, element;
list = document.getElementsByClassName('box-title');
for (index = 0; index < list.length; ++index){
element = list[index].innerHTML;
if(element == "Related Products"){
list[index].innerHTML = "Choose Extra To make It More Special";
alert("Page is loaded");
}
}
}
</script>
</head>
<body onload =”changeValue()”>
<div class="box-title">Related Products</div>
</body>
</html>
答案 0 :(得分:1)
也许您必须删除onload和=之间的空格并更改奇怪的双引号(也称为“智能引号”)
所以这个:
<body onload =”changeValue()”>
将是这样的:
<body onload="changeValue()">
答案 1 :(得分:0)
您是否尝试过更改++
运营商?
<!DOCTYPE html>
<html>
<head>
<script language="javascript" type="text/javascript">
function changeValue()
{
var list, index, element;
list = document.getElementsByClassName('box-title');
for (index = 0; index < list.length; index++)
{
element = list[index].innerHTML;
if(element == "Related Products")
{
list[index].innerHTML = "Choose Extra To make It More Special";
alert("Page is loaded");
}
}
}
</script>
</head>
<body onload =”changeValue()”>
<div class="box-title">Related Products</div>
</body>
</html>
答案 2 :(得分:0)
有很多原因可能无法正常工作。
例如,浏览器可能不支持getElementsByClassName()
。