【发布时间】:2010-06-21 19:21:43
【问题描述】:
我有一些新闻链接,当用户继续前进时,我必须更改包含详细新闻的段落文本。
【问题讨论】:
标签: jquery onmouseover
我有一些新闻链接,当用户继续前进时,我必须更改包含详细新闻的段落文本。
【问题讨论】:
标签: jquery onmouseover
很简单:
$('a.newslink').bind('mouseover', function() {
$('p#newsdetail').text('new text');
})
【讨论】:
您能否发布一些示例代码或您正在使用的/目前拥有的内容?没有那个,我只能推荐你到这个页面:http://api.jquery.com/mouseover/
【讨论】:
在此处查看实际解决方案:http://jsbin.com/asoka4/2
这是一种非常懒惰的做事方式=)
<script type='text/javascript'>
$( function() {
$("#news li").hover(
function () {
$(this).attr('small',$(this).html());
$(this).html($(this).attr('full'));
},
function () {
$(this).html($(this).attr('small'));
}
);
});
</script>
<ul id='news'>
<li id='news1' full='<strong>this is the full news 1</strong>'>This is some news 1</li>
<li id='news2' full='<del>This is the full news 2</del>'>This is some news 2</li>
<li id='news2' full='<a href="http://www.google.com">Check google.com for this one!'>This is some news 3</li>
</ul>
【讨论】:
如果这是您的要求,我不肯定,但请尝试使用 jQuery 的 .html() method。它为元素设置innerHTML 属性,并允许您更改<p> 元素的文本。
【讨论】: