Created
April 25, 2014 21:33
-
-
Save arbaouimehdi/11304080 to your computer and use it in GitHub Desktop.
It is very simple to get content inside DIVs or inside others tags with jQuery, however, the complexity come when we try to get a particular text between two HTML tags, here is an example of solution:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="parent"> | |
<div class="first">first</div> | |
<div class="child1">child1</div> | |
Paragraph 1 | |
<br> | |
Paragraph 2 | |
<br/> | |
Paragraph 3 | |
<div class="child2">child2</div> | |
<div class="child3">child3</div> | |
Last Content | |
<br/> | |
Last Content 2 | |
<br/> | |
Last Content 3 | |
<div class="last">last</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var appendSt = $('.child3').after('code:'), | |
content = $('.parent').clone().children().remove().end().text(), | |
reg = content.replace(/code:([^xyz]+)/, ''); | |
alert(reg); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment