2

I have some news links, when user moves on that I have to change text of paragraph containing news in details.

nectar
  • 9,525
  • 36
  • 78
  • 100

4 Answers4

7

It's simple:

$('a.newslink').bind('mouseover', function() {
   $('p#newsdetail').text('new text');
})
vtambourine
  • 2,109
  • 3
  • 18
  • 27
2

Can you post some example code or what you are working with/what you have so far? Without that, I can only refer you to this page: http://api.jquery.com/mouseover/

Chris Laplante
  • 29,338
  • 17
  • 103
  • 134
1

see solution in action here: http://jsbin.com/asoka4/2

This is a really lazy way to do things =)

<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>
ruinernix
  • 690
  • 2
  • 8
  • 21
0

I'm not positive if this is what you're asking, but try using jQuery's .html() method. It sets the innerHTML property for an element, and it'll let you change the text of a <p> element.

octopi
  • 2,004
  • 1
  • 12
  • 16