在鼠标指针下获取单词

according this (get a word under cursor using JavaScript )link i can get word under mouse pointer.it's fine for english language. i change it (for arabic language)

<p>سلام به همه</p>
Word: <span id="word"></span>

<script type="text/javascript">
    $(function() {
        // wrap words in spans
        $('p').each(function() {
            var $this = $(this);
            $this.html($this.text().replace(/[^\x00-\x80]+/g, "<span>$1</span>"));
        });

        // bind to each span
        $('p span').hover(
            function() { $('#word').text($(this).css('background-color','#ffff66').text()); },
            function() { $('#word').text(''); $(this).css('background-color',''); }
        );
    });

but it return '$1' for each word. please help!

查看全部
weixin_33749242
weixin_33749242
2012/07/07 07:20
  • browser
  • html
  • ajax
  • javascript
  • 点赞
  • 收藏
  • 回答
    私信

1个回复