Build A Selector Automatically From Inputs Attributes
I'm developing a generator something like a website builder where I am fetching the values from the name attributes of inputs fields and sending that to the editor. I don't know ho
Solution 1:
You can list the attribute names in an array and loop through them:
case 'icons':
var iconAttributes = ['style', 'size', 'color'],
ret = '', value;
$.each(iconAttributes , function (id, attrib) {
value = jQuery('[name="icons_' + attrib + '"]').val();
if(value !== '') {
ret += ' ' + attrib + '="' + value + '"';
}
});
return '\n[icons' + ret + ']\n';
break;
Post a Comment for "Build A Selector Automatically From Inputs Attributes"