更改HREF链接的名称

时间:2010-02-04 09:36:55

标签: php jquery href mouseover

我有以下链接

<a href="example.com" id="example1"> Go to example....</a>

当身体将光标移到“转到示例...”时,它可能会变为“转到示例一”,我正在使用php和jquery。任何帮助将不胜感激。

6 个答案:

答案 0 :(得分:3)

使用jQuery不应该太困难:

$('#example1')
    .mouseover(function(e) { $(this).text('Go to example One') })
    .mouseout(function(e) { $(this).text('Go to example...') });

如果您不需要它,当用户将鼠标移开时,请删除第二个绑定。

编辑:忘记鼠标悬停辅助方法

答案 1 :(得分:3)

试试这个..

$('#example1').mouseover(function() {
    $(this).text('Go to example One');
});

雅错过了#我试图快速进入;)

答案 2 :(得分:3)

$(function(){
    $("#example1").mouseover(function(){
        $(this).text('Go to example One');
    });
});

或者您可以使用 hover 功能,例如

$(function(){
    $("#example1").hover(
      function () {
        $(this).text('Go to example one');
      }, 
      function () {
        $(this).text('Go to example....');
      }
    );
});

答案 3 :(得分:1)

.hover()帮助程序在这里很有用,可以防止恼人的事件冒泡:

var elem = $('#examle1'), orig = elem.text();
elem.hover(
    function() { $(this).text('Go to example One'); },
    function() { $(this).text(orig); }
);

答案 4 :(得分:1)

你甚至可以用CSS做到这一点。您只需要链接中的两个元素即可:

<a href="example.com" id="example1"> Go to example <em>…</em> <span>One</span></a>

相应的CSS行为:

a span,
a:hover em {
    display: none;
}
a:hover span {
    display: inline;
}

答案 5 :(得分:0)

这是PHP代码

<span
class="trackTitle"> <a href="<?php print  "play/".$link;?>" title="Listen or Download <?php echo $hoverActual ?>"  onmouseover="javascript:changeTo('<?php echo $hoverActual; ?>');"><?php echo $fileName; ?></a></span>

使用Function changeTo,我想更改$ fileName; 。

相关问题