html代码:
<span class="col1">手机号:</span>
<input id="phone" class="inpu_reg" type="text" maxlength="11" size="30" name="phone" autocomplete="off" />
<b id="phone_tip" class="regtips"></b>
<a οnclick="IsMobile()"></a>
JS代码:
function IsMobile(){
var phone=document.getElementById("phone");
var tip=phone.nextSibling;
//判断下一个节点的nodeType是否为1,为1就说明是标签,否则继续向下寻找
while(tip.nodeType!=1){ tip=tip.nextSibling;}
//向找到的b标签中增加提示信息
tip.innerHTML="请输入正确的手机号码";
}