在运行时在javascript中为标签赋值 [英] assign value to a label at runtime in javascript

查看:72
本文介绍了在运行时在javascript中为标签赋值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Experts,

onkeyup function of a texbox i am checking that if username already exists or not in my database.
everything work fine when i tested it into a new application.
But when i am trying to use it into my actual application it doesn't work...

my actual page is a content page of a master page... and the code below:

<pre lang="Javascript"><script language ="javascript" type = "text/javascript">


    function OnSucceeded(result,userContext, methodName)
    {
        alert(result);
        var userarray=result;
        document.getElementById('lblerror').innerHTML=userarray;
        // Not working

    }
</script> </pre>

document.getElementById('lblerror').innerHTML=userarray;.... Line is not working i am not getting the .innerHTML property while typing...

help me to assing value of userarray into label lblerror...


Thanks...

推荐答案

你可以使用: -



you can use :-

document.getElementById('lblerror').innerText=userarray;






Or

document.getElementById('lblerror').textContent=userarray;


你可以尝试这样的事情



document.getElementById('< %= lblID.ClientID%>')。childNodes [0] .nodeValue ='您的值';
you can try something like this

document.getElementById('<%=lblID.ClientID %>').childNodes[0].nodeValue = 'Your value';


您好


尝试使用 innerText 属性



Hi
Try with innerText property

var lblerror = document.getElementById('<%= lblerror.ClientID %>');
           lbl.innerText = ' value changed';


这篇关于在运行时在javascript中为标签赋值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆