Reputation: 469
I have the following link
<a href="example.com" id="example1"> Go to example....</a>
Is it possible that when a body moves the cursor over "Go to example..." it changes to "Go to example One" , i am using php and jquery. Any help will be appreciated.
Upvotes: 0
Views: 4183
Reputation: 655189
You can even do that with CSS only. You just need two elements in your link that you can address like:
<a href="example.com" id="example1"> Go to example <em>…</em> <span>One</span></a>
And the corresponding CSS behavior:
a span,
a:hover em {
display: none;
}
a:hover span {
display: inline;
}
Upvotes: 1
Reputation: 108490
The .hover()
helper is useful here, to prevent annoying event bubbling:
var elem = $('#examle1'), orig = elem.text();
elem.hover(
function() { $(this).text('Go to example One'); },
function() { $(this).text(orig); }
);
Upvotes: 1
Reputation: 469
here is the PHP code
<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>
where the Function changeTo is used, i want to change $fileName; .
Upvotes: 0
Reputation: 2465
Try this out..
$('#example1').mouseover(function() {
$(this).text('Go to example One');
});
Ya missed the # I was trying to get in quick ;)
Upvotes: 3
Reputation: 187030
$(function(){
$("#example1").mouseover(function(){
$(this).text('Go to example One');
});
});
or you can use the hover function like
$(function(){
$("#example1").hover(
function () {
$(this).text('Go to example one');
},
function () {
$(this).text('Go to example....');
}
);
});
Upvotes: 3
Reputation: 84734
Shouldn't be too difficult using jQuery:
$('#example1')
.mouseover(function(e) { $(this).text('Go to example One') })
.mouseout(function(e) { $(this).text('Go to example...') });
Remove the second bind if you don't need it to go back to "..." when the user moves the mouse away.
Edit: Forgot about the mouseover helper method
Upvotes: 3