javascript - Get text value using name attirbute one by one -
i have 3 elements of html
<h3 contenteditable class="education" name="education[index][university]>1</h3> <span contenteditable class="education" name="education[index][time]>2</span> <p contenteditable class="education" name="education[index][description]>3</p>
so want text value order h3-span-p 1 one using name attribute javascript.after every value how can have new line follow after this
1 2 3
thanks in advanced
try this:
$(function() { var output = $('[name^="education[index]"]').map(function() { return $(this).html(); }).get().join('\n'); alert(output); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <h3 contenteditable name="education[index][university]">1</h3> <span contenteditable name="education[index][time]">2</span> <p contenteditable name="education[index][description]">3</p>
update:
if have education class can call $('.education').map...
Comments
Post a Comment