关于jquery的live()的小问题
我将如何更改标签的 html,如下所示:
$('#someId').html('
foo bar
');
在使用 live() 或 delegate() 函数时?只是为了澄清,我不希望这种情况发生在悬停、焦点或单击时...我只是希望 jquery 立即更改某个标签内的 html。
基本上,我试图更改 Mojomotor 的小下拉面板中的徽标,并且我不想每次升级到新版本时都更改徽标。
有什么建议吗?
How would I change the html of a tag like so:
$('#someId').html('<p>foo bar</p>');
while using the live() or delegate() function? Just for clarification I don't want this to happen on hover or focus or click... I just want jquery to immediately change the html inside of a certain tag.
Basically, I'm trying to change the logo in the Mojomotor's little dropdown panel and I don't want to change the logo every time I upgrade to a new version.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
.live()
和.delegate()
不是这样工作的,你所追求的仍然是通过.livequery()
插件 或直接在文档中。准备好
(如果页面加载时出现),如下所示:或者使用
.livequery( )
如果在页面中动态替换:.live()< /code>
和
.delegate()
工作事件冒泡...刚刚出现的元素不会执行此操作,而click
或change
等会执行此操作。.live()
and.delegate()
don't work like this, what you're after is still done through the.livequery()
plugin or simply in thedocument.ready
if it's present on page load, like this:Or with
.livequery()
if it's replaced dynamically in the page:.live()
and.delegate()
work off of event bubbling...an element just appearing doesn't do this whereas aclick
orchange
, etc would.只需在 DOM 加载时执行即可。
Just do it when the DOM loads.