jQuery 标签后加提示信息

html 部分

<input type="text" id="test" onclick="check();"></input>

 

jquery 部分

function msgshow(tar,msginfo){
  tar.after("<span datatype='msg' style='color:red'>"+msginfo+"</span>");
}
function msghide(tar){
  tar.nextAll().each(function(){
    var dt=$(this).attr("datatype");
    if(dt=="msg"){
      $(this).remove();
    }
  });
}

function check(){

  var id=$("#id");

  if(id.val()!=""){

    megshow(id,"内容不能为空!");

  }

  else{

    meghide(id);

  }

};

posted @ 2015-07-23 10:24  yunchong1019  阅读(150)  评论(0编辑  收藏  举报