刷新div的问题

发布于 2024-10-09 02:16:50 字数 762 浏览 0 评论 0原文

我有一个 div 如下: 一

var a = document.getElementById("xyz") ;
alert(a); //prints one
var b = document.getElementById("xyz").innerHTML ="two" ;
alert(b);  //prints two

但是我的文本“二”没有反映在UI中,div文本如何没有反映在UI上。有什么方法可以强制刷新div。div不是普通的div。有一些jquery插件可以将 div 转换为锚点的工具提示。这样,当我将鼠标悬停在锚点上时,我可以看到工具

提示 编辑:这是标题如何附加到工具提示

<a alt="" class="tooltipcls"
 style="background: transparent url(xyz.gif)  bla bla bla; 
 title="#idofdiv" href="javascript:void(0);"
 dojoAttachPoint="abc"
 dojoAttachEvent="onmouseover:_populatetooltip"
 ></a>
<div dojoAttachPoint="aksabc1" id="idofdiv" style="display: none; position: absolute;">pop
up content here </div>

查看标题如何附加到 div。我运行他们的脚本,工具提示关联起来与锚

I have a div as follows:
one

var a = document.getElementById("xyz") ;
alert(a); //prints one
var b = document.getElementById("xyz").innerHTML ="two" ;
alert(b);  //prints two

But my text "two" is not reflected in UI ,How div text is not getting reflected on UI.Is there any means by which i can forcefully refresh the div.The div is not a normal div .There is some jquery plugin that converts div into tooltip of a anchor.so that when i hover mouse over anchor i can see the tooltip

EDIT:Here is how title is attached to tooltip

<a alt="" class="tooltipcls"
 style="background: transparent url(xyz.gif)  bla bla bla; 
 title="#idofdiv" href="javascript:void(0);"
 dojoAttachPoint="abc"
 dojoAttachEvent="onmouseover:_populatetooltip"
 ></a>
<div dojoAttachPoint="aksabc1" id="idofdiv" style="display: none; position: absolute;">pop
up content here </div>

See how title is attached to a div.I run a their script and tool tip gets associated with the anchor

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

迷你仙 2024-10-16 02:17:02

“B”和“I”必须大写。

Javascript 是区分大小写的语言。 Javascript函数一般使用小驼峰式来拼写,该方法称为getElementyById

这是来自 W3C 学校

名为“myfunction”的函数与“myFunction”不同,名为“myVar”的变量与“myvar”不同。

JavaScript 区分大小写 - 因此在创建或调用变量、对象和函数时请密切注意大小写。

The "B" and the "I" must be capitalized.

Javascript is a case-sensitive language. Javascript functions are generally spelled using lower camel case, the method is called getElementyById.

This is from W3C Schools:

A function named "myfunction" is not the same as "myFunction" and a variable named "myVar" is not the same as "myvar".

JavaScript is case sensitive - therefore watch your capitalization closely when you create or call variables, objects and functions.

南城旧梦 2024-10-16 02:16:59

您可以使用以下 Jquery 函数来更改 div 的内部文本

  $("div#xyz").html('two');

you can use following Jquery function to change inner text of div

  $("div#xyz").html('two');
吾性傲以野 2024-10-16 02:16:58

JavaScript 区分大小写。它应该是getElementById。尽管如此,这可能不是您正在寻找的答案。


编辑:问题是可能(因为您没有向我们展示完整的代码)您的工具提示插件正在抓取div的文本当你初始化插件时。所以,基本上,您可以再次调用该函数:

document.getElementById('xyz').innerHTML = "two";
$('.tooltip').tooltip(); // The code that initializes your plugin

同样,不是非常理想或其他什么。我们没有足够的代码可供使用。 :(

Javascript is case-sensitive. It should be getElementById. Although, that might not be the answer you're looking for.


EDIT: The problem is probably (since you're not showing us your complete code) that your tooltips plugin is grabbing the div's text when you initialize the plugin. So, basically, you can call that function again:

document.getElementById('xyz').innerHTML = "two";
$('.tooltip').tooltip(); // The code that initializes your plugin

Again, not very optimal or anything. We don't have enough code to work with. :(

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文