jQuery - Get all h2 text, and put it in other div -
i need help. have select h2 tags from
<div id = "result"> ... </ div> and put text h2 other giant
<div id = "h2-results"> </ div> also, when click on text h2 result, have move page h2 in <div id = "result">
edit:
code:
$('#result h2').each(function() { $('#h2-results ul').append($('<li/>', {text: $(this).text()}); }); simple: [result]
<h2>first</p> <p>some text here</p> <h2>second</p> <p>some text here</p> <h2>third</p> <p>some text here</p> [h2-results]
<ul> <li>first</li> <li>second</li> <li>third</li> </ul> and when click on etc. <li>second</li> scrroltop
<h2>second</p> <p>some text here</p>
create empty ul tag in div h2-results.
<div id="h2-results"> <ul></ul> </div> or append in jquery h2-results.
$("#h2-results").empty (); $("#h2-results").append("<ul/>"); loop result div shown below.
$("#result").find("h2").each(function() { $("#h2-results ul").append('<li>' +this.innertext+'</li>'); });
Comments
Post a Comment