开发者

How to take text from one place then render at other place on same page?

开发者 https://www.devze.com 2023-01-14 03:10 出处:网络
<div id=\"default\"> <h2> heading </h2> <div id=\"开发者_如何转开发big-on-hover\">
<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.


You could try something like this:

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

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


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();;
    });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消