2
I have a "span" with properties date:
<span data-label="Name" data-icon="user"></span>
And in the script I have a variable with objects:
var widgets = {
options: {
label: null,
icon: null
}
};
How can I search and put the values of date inside the objects???
edição
I tried to put as it is in the question to facilitate, but apparently it complicated more. I apologize kkkkk
But here’s the thing I’m looking to create "widgets" to perform their roles in accordance with the "data-role" provided, then it performs the respective function, with some options that can give more information than in case are other "date-...", follows the code:
$.widget = function(name, parameters){
$(document).ready(function(){
var widgets = $("[data-role=" + name + "]");
Object.keys(parameters.options).forEach(function(key){
parameters.options[key] = widgets.data(key);
});
parameters._create(widgets);
});
};
var widget = $.widget;
$.widget("input", {
options: {
label: null,
icon: null
},
_create: function(element){
var o = this.options;
$("<span/>").addClass("label fg-" + _theme_featured).text(o.label).appendTo(element);
But it just collects data from the first and adds in all, I would like it to be individual
Thank you very much it worked, but it does not do individual, how do I apply this with several spans individually each with its value? I tried to use the :eq() in the selection but only did with the first
– user45722
@Vinicius as you want the data on
widgets? you want awidgetsfor each element or you want onewidgetswith everyone’s data? You can give an example of the final data you want?– Sergio
Edited question
– user45722