2

ユーザーが移動すると、ニュースを含む段落のテキストを詳細に変更する必要があるニュースリンクがいくつかあります。

4

4 に答える 4

7

簡単だ:

$('a.newslink').bind('mouseover', function() {
   $('p#newsdetail').text('new text');
})
于 2010-06-21T19:26:09.760 に答える
2

いくつかのサンプルコードまたはあなたが取り組んでいるもの/あなたがこれまでに持っているものを投稿できますか?それがなければ、私はあなたにこのページを参照することしかできません:http: //api.jquery.com/mouseover/

于 2010-06-21T19:27:22.860 に答える
1

ここで実際のソリューションを参照してください: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>
于 2010-06-21T22:02:45.633 に答える
0

これがあなたが求めているものであるかどうかはわかりませんが、jQueryの.html() メソッドを使用してみてください。innerHTML要素のプロパティを設定し、要素のテキストを変更できるようにします<p>

于 2010-06-21T19:26:15.380 に答える