我是JavaScript的最新版本。我遇到了一个问题。请帮忙。
下面是Html代码源,
<BODY onload="initForm(document.frmTKTNetRemitCC)" onkeydown ="bodyOnKeyDown('onSendValidate(document.frmTKTNetRemitCC)')" scroll="no">
<FORM name="frmTKTNetRemitCC">
<TABLE width="100%" BORDER="0">
<TR><TD width="100%">
<FIELDSET>
<LEGEND class="TITLE">[LABEL id="TITLE_FOP_FARE"]</LEGEND>
<TABLE width="100%" CELLSPACING="0" CELLPADDING="0" border="0">
<TR><TD>
<TABLE width="100%" border="0">
<!--Form of Payment-->
<TR>
<TD width="1px" rowspan="5"></TD>
<TD id="LBL_NETREMIT_FORMOFPAYMENT" class="LBL" LabelType="MANDATORY" Tooltip="[LABEL id="TIP_NETREMIT_FORMOFPAYMENT"]" width="1%">[LABEL id="LBL_NETREMIT_FORMOFPAYMENT"]</TD>
<TD><SELECT class="CBO" id="selfop" name="selfop" Tooltip="[LABEL id="TIP_NETREMIT_FORMOFPAYMENT"]" style="width:95px"></SELECT></TD>
下面的JS测试代码源:
function initForm(p_objForm)
{
try
{
alert(document.getElementById("LBL_NETREMIT_FORMOFPAYMENT").Tooltip);
document.getElementById("LBL_NETREMIT_FORMOFPAYMENT").setAttribute("Tooltip", "Test Tooltip");
alert(document.getElementById("LBL_NETREMIT_FORMOFPAYMENT").Tooltip);
结果是当警告Tooltip值时,它显示正确的更改。但工具提示值显示仍保持不变。是否需要刷新页面?工具提示属性操作与document.getElementById("LBL_NETREMIT_FORMOFPAYMENT").innerHTML = ?"?
-------更新更多细节
CLASS =&#34; LBL&#34;
.LBL { behavior: url([APP id="HTMLROOT"]\AMEX\AX_COMMON\Labels.htc);
FONT-FAMILY:ARIAL;
COLOR:BLACK;
FONT-SIZE:11px;
FONT-WEIGHT:BOLD;
}
Label.htc
<PUBLIC:COMPONENT>
<PUBLIC:PROPERTY NAME="LabelType" INTERNALNAME="g_vLabelType"/>
<PUBLIC:PROPERTY NAME="EncoderName" INTERNALNAME="g_vEncoderName"/>
<PUBLIC:PROPERTY NAME="FieldEncoderPopulate" INTERNALNAME="g_vFieldEncoderPopulate"/>
<PUBLIC:PROPERTY NAME="ToolTip" INTERNALNAME="g_vToolTip"/>
<PUBLIC:PROPERTY NAME="DateFormat" INTERNALNAME="g_vDateFormat"/>
<PUBLIC:PROPERTY NAME="OnFieldEncoderPopulate" INTERNALNAME="g_vOnFieldEncoderPopulate"/>
<PUBLIC:PROPERTY NAME="isExternalObj" INTERNALNAME="g_vIsExternalObj"/>
g_vTooTip
function DoInit()
{
g_vDocument = document;
g_vStyle = this.style;
try
{
if(g_vLabelType==null)g_vLabelType="NORMAL";
}
catch(e)
{
}
if(g_vToolTip!=null) this.title = g_vToolTip;
this.className = g_vLabelType;
}
提前致谢。
答案 0 :(得分:0)
在HTML DOM中,它不是ToolTip
,而是title
。
更改...
alert(document.getElementById("LBL_NETREMIT_FORMOFPAYMENT").Tooltip);
document.getElementById("LBL_NETREMIT_FORMOFPAYMENT").setAttribute("Tooltip", "Test Tooltip");
alert(document.getElementById("LBL_NETREMIT_FORMOFPAYMENT").Tooltip);
要...
alert(document.getElementById("LBL_NETREMIT_FORMOFPAYMENT").title);
document.getElementById("LBL_NETREMIT_FORMOFPAYMENT").setAttribute("title", "Test Tooltip");
alert(document.getElementById("LBL_NETREMIT_FORMOFPAYMENT").title);