Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacing div html like toggle

I have a div and i want to replace its html on hover, but on hover back i want to replace it back to it previous html. (like toggle...)

code:

<div class="container">
    <div class="inner first">Hello</div>
    <div class="inner second">And</div>
    <div class="inner third">Goodbye</div>
</div>

i try this

$(".inner").mouseover(function() {
    var tmpX = $(this).html();
    $(this).html("xxxxxxxxxxxx");
}).mouseout(function() {
    $(this).html(tmp);
});

Thanks

like image 633
sortof Avatar asked Sep 16 '26 03:09

sortof


1 Answers

You need to make the tmpX variable as global

var tmpX;
$(".inner").mouseover(function() {
    tmpX = $(this).html();
    $(this).html("xxxxxxxxxxxx");
}).mouseout(function() {
    $(this).html(tmpX);
});

Fiddle

like image 78
Anoop Joshi P Avatar answered Sep 17 '26 17:09

Anoop Joshi P



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!