I have this code:
jQuery(document).ready(function($) {
var i = 0;
var values = [];
var element = $('.source');
element.each(function(i) {
values[i++] = $(this).text();
});
});
I want to assign each array value above, as the individual data-text value on another set of list elements. Something like this:
<ul id="list">
<li data-text="arrayvalue1"></li>
<li data-text="arrayvalue2"></li>
<li data-text="arrayvalue3"></li>
</ul>
I don't understand how I would do this using jQuery.
$(this).attr('data-text')$(this).data('text')$(this)[0].dataset['text'].sourceholds the elements we are pulling from. The html already exists for adding thedata-textattributes, I just don't know how to pull from one array and inject thedata-textattributes to another