鼠标悬停脚本无效...需要帮助

时间:2010-10-13 17:21:01

标签: javascript events

有人可以尝试这个,看看它是否适合你。我无法弄清楚问题..也许我在某处发生了冲突。使用jquery。

非常感谢您的帮助。

  <script type="text/javascript">
  $(document).ready(function(){
  $('a').mouseover(function() {
  switch ($(this).attr('class')) {
  case 'nc1':
    new_content = 'Twitter';
    break;

  case 'nc2':
    new_content = 'Facebook';
    break;

  case 'nc3':
    new_content = 'Linked In';
    break;

  case 'nc4':
    new_content = 'Flickr';
    break;
  case 'nc5':
    new_content = 'RSS Feed';
    break;

  case 'cs1':
    new_content = 'Email';
    break;
  case 'cs2':
    new_content = 'Telephone';
    break;

  case 'cs3':
    new_content = 'Live Chat';
    break;

  case 'cs4':
    new_content = 'Skype';
    break;

  case 'cs5':
    new_content = 'Google Voice';
    break;

  default:
    new_content = 'The crusade to feed every orphan in the world';
    break;
  }

  $('#ms').html(new_content)
  }).mouseout(function() {
  $('#ms').text('The crusade to feed every orphan in the world');
  });});
  </script>




  <div id="ms">The crusade to feed every orphan in the world.</div>

  <div id="nc_wrap2">
  <a class="nc1" href="#"></a>
  <a class="nc2" href="#"></a>
  <a class="nc3" href="#"></a>
  <a class="nc4" href="#"></a>
  <a class="nc5" href="#"></a>
  </div>

1 个答案:

答案 0 :(得分:1)

如果您在链接中添加了一些内容, 就可以正常工作 ......

示例http://www.jsfiddle.net/x4Lm4/