jquery - Cannot Display paragraph preview in pop-up window -
i have problem displaying text
tag pop-up, experiencing reference errors, can refer p tag until show p tag using .click function, need taking displayed p tag after click function , outputting hover pop-up function here code.
$('.article h1 a').click(function(event) { event.preventdefault(); $(this.parentnode).next('p').fadetoggle(1000); $(this.parentnode).next('p').hover(function() { var paragraph = $(this).next('p').text(); $('#pop-up').find('h3').append(paragraph); $('#pop-up').show(); }, function() { $('#pop-up').hide(); }); }); here html code:
<div id="content"> <div class="column"> <div class="article"> <img src="images/stevejobs.png" alt="steve jobs" title="stevejobs" /> <h1><a href="#"> computers changed forever</a></h1> <p> brilliant mind of steve jobs. </p> <a href="#" id="trigger">this link</a> <!-- hidden / pop-up div --> <div id="pop-up"> <h3>pop-up div displayed</h3> </div> </div>
problem @ var paragraph = $(this).next('p').text();
i think want var paragraph = $(this).text();
inside $(this.parentnode).next('p').hover(function() { this paragraph node
$('.article h1 a').click(function(event) { event.preventdefault(); $(this.parentnode).next('p').fadetoggle(1000); $(this.parentnode).next('p').hover(function() { var paragraph = $(this).text(); if( !$('#pop-up').data("appended")){// removes multiple appending $('#pop-up').find('h3').append(paragraph); $('#pop-up').data("appended",true) } $('#pop-up').show(); }, function() { $('#pop-up').hide(); }); });
Comments
Post a Comment