JScript innerHTML值 [英] JScript innerHTML value

查看:78
本文介绍了JScript innerHTML值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!


在以下JScript函数中:


功能 cancelClick()


{


var gridView = document.getElementById( " GridViewNewsHead" );



var gridViewlength = document.getElementById( " GridViewNewsHead" )。rows.length;


var gridViewTextBox = gridView.rows [gridViewlength - 1] .cells [0];


var gridViewTextBoxinnerHTML = gridViewTextBox.innerHTML;



}

我得到了以下innerHTML值:

< INPUT id = GridViewNewsHead_ctl04_TextBox2 style =" WIDTH:99%" tabIndex = 0 value =欧洲名称= GridViewNewsHead $ ctl04 $ TextBox2 autocomplete =" off"> < INPUT id = GridViewNewsHead_ctl04_twNhAdd_ClientState tabIndex = 0 type = hidden name = GridViewNewsHead $ ctl04 $ twNhAdd_ClientState> < SPAN id = GridViewNewsHead_ctl04_rfvForNH style =" DISPLAY:none;颜色:红色"的ControlToValidate = QUOT; GridViewNewsHead_ctl04_TextBox2" errormessage ="请输入主标题"显示= QUOT;无" initialvalue isvalid =" true">< / SPAN>< INPUT id = GridViewNewsHead_ctl04_vcFname_ClientState tabIndex = 0 type = hidden name = GridViewNewsHead $ ctl04 $ vcFname_ClientState>

从上面的innerHTML值,我想得到在JScript函数中id为'GridViewNewsHead_ctl04_TextBox2'的值。

请帮助。



PS:其实我试图获取id GridView TextBox(动态添加),同时取消添加行上的Ajax确认框!

解决方案



我们可以检索如下所示的完整ID:

var gridView = document.getElementById(<%= GridViewNewsHead.ClientID %> );

原因我们需要使用ServerSide变量是ASP.Net将容器名称添加到id中以保持它在页面中的唯一性。


谢谢


Hi!


In the following JScript function:

function cancelClick()

{

var gridView = document.getElementById("GridViewNewsHead");

var gridViewlength = document.getElementById("GridViewNewsHead").rows.length;

var gridViewTextBox = gridView.rows[gridViewlength - 1].cells[0];

var gridViewTextBoxinnerHTML = gridViewTextBox.innerHTML;

}

I got the following innerHTML value:

<INPUT id=GridViewNewsHead_ctl04_TextBox2 style="WIDTH: 99%" tabIndex=0 value=Europe name=GridViewNewsHead$ctl04$TextBox2 autocomplete="off"> <INPUT id=GridViewNewsHead_ctl04_twNhAdd_ClientState tabIndex=0 type=hidden name=GridViewNewsHead$ctl04$twNhAdd_ClientState> <SPAN id=GridViewNewsHead_ctl04_rfvForNH style="DISPLAY: none; COLOR: red" controltovalidate="GridViewNewsHead_ctl04_TextBox2" errormessage="Please Enter Main Heading" display="None" initialvalue isvalid="true"></SPAN><INPUT id=GridViewNewsHead_ctl04_vcFname_ClientState tabIndex=0 type=hidden name=GridViewNewsHead$ctl04$vcFname_ClientState>

From the above innerHTML value, I want to get the value of id that is 'GridViewNewsHead_ctl04_TextBox2' in the JScript function.

Please help.

Thanks


PS: Actually, I was trying to get the id of GridView TextBox (added dynamically) while cancelling the Ajax Confirmation Box on Add row!

解决方案

Hi ,

we could retrieve the full id like this:

var gridView = document.getElementById(<%=GridViewNewsHead.ClientID%>);

the reason that we need to use ServerSide variable is ASP.Net will add the container name to the id to keep it's unique in the page.


Thanks


这篇关于JScript innerHTML值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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