<script type="text/javascript">
function changeText(){
document.getElementById('boldStuff').innerHTML = 'Fred Flinstone';
}
</script>
<p>Welcome to the site <b id='boldStuff'>dude</b> </p>
<input type='button' onclick='changeText()' value='Change Text'/>
还可以加样式
function getmeiquan(){
//var n=document.getElementById('username').value;
//alert (n);
var a=999;
var str = "<span style='font-weight:700; font-size:16px'>";
var str =str+a+"</span>";
document.getElementById('boldStuff').innerHTML = str;
//location.reload();
}
==============================================完整的如下
1、下拉框,选 是或否 触发事件
<select id="meiquanId" name="meiquan" onChange="getmeiquan()">
<option selected="" value="0">否</option>
<option value="1">是</option>
</select>
2、正常显示,第一次加载时的初始数据
<p class="pull-right" id='boldStuff'>
<span style="font-weight:700; font-size:16px">¥
{$yingfu}
</span>
</p>
3、事件,改变html标签id='boldStuff里的内容 [注: 放在页头]
<srcipt>
function getmeiquan(){
var text = document.getElementById('meiquanId').value;
//alert(typeof(text));
if(text == '1' ){
var a=999;
var str = "<span style='font-weight:700; font-size:16px'>¥ ";
var str =str+a+"</span>";
document.getElementById('boldStuff').innerHTML = str;
}
if(text == '0'){
var a=888;
var str = "<span style='font-weight:700; font-size:16px'>¥ ";
var str =str+a+"</span>";
document.getElementById('boldStuff').innerHTML = str;
}
//location.reload();
}
</script>
=========================
另,改变一下标签内容
js
<script>
var str = '<a class=\'wx_zf pull-left\' href=javascript:zhifu(\'index.php?s=/addon/WeiSite/Alipay/index/cartid/'+id+'/addid/'+addinfoid+'/invid/'+invoiceid+'/couponsid/'+couponsid+'/paytype/2/type/'+type+'/fu/'+fu+'/apply_meibi/'+apply_meibi+'\','+addinfoid+')'+'>微信支付</a>';
document.getElementById('tihuan').innerHTML = str;
</script>
html
<div id="tihuan"><a id='boldStuff2' href="javascript:zhifu('index.php?s=/addon/WeiSite/Alipay/index/cartid/{$id}/addid/{$addinfo['id']}/invid/{$invoice['id']}/couponsid/{$coupons['id']}/paytype/2/type/{$type}',{$addinfo['id']})" class="wx_zf pull-left" >微信支付</a></div>