views:

71

answers:

2
<div id="default">
<h2> heading </h2>

<div id="big-on-hover">
<h2> heading </h2>

I want to render the text of h2 of <div id="default"> in <div id="big-on-hover"> because both will be same always so I will change at one place it will show all other places also.

A: 

You could try something like this:

$(document).ready(function() {
            $('#default h2').mouseover(function() {

            var text = $('#default h2').html();
            $('#big-on-hover h2').html(text);
            });
        });
Andy Rose
A: 

If i understood it correctly this is what you want.

jQuery(document).ready(function(){
    jQuery('#default').hover(function(){
        var hoverhtml = "<h2>" + jQuery('#default h2').html() + "</h2>" + jQuery('#big-on-hover').html();
        jQuery('#big-on-hover').html(hoverhtml);
    },
    function(){
        jQuery('#big-on-hover h2').remove();;
    });
});
Amit
@Amit - I want to add <h2> on hover don't want to keep before.
metal-gear-solid
You will need a placeholder to append the h2 on hover. Like a div or something in its place.
Amit
@Amit - I want to add same `h2` of "default" as a first thing inside `<div id="big-on-hover">`
metal-gear-solid
I modified it. Should do what you need.
Amit