Skip to content

Instantly share code, notes, and snippets.

@iqbalrony
Last active February 11, 2021 07:06
Show Gist options
  • Select an option

  • Save iqbalrony/2667aa4e70f4d05ccbc67602866ed169 to your computer and use it in GitHub Desktop.

Select an option

Save iqbalrony/2667aa4e70f4d05ccbc67602866ed169 to your computer and use it in GitHub Desktop.
Get all icon class name or data attribute from console panel by jQuery and JavaScript. ( get class name, get attribute )
//Run all following codes in a browser console panel
var cls_array = []; //array declaration (or var cls_array = new Array())
console.log(typeof cls_array); //type var type check
var icon_tags = $('.icons i'); //variable declaration for icon tag. you set your class name whatever you need
console.log(icon_tags.length);
icon_tags.each(function () {
var $self = $(this),
$cls = $self.attr('class'); //get icon class name or id name
cls_array.push($cls); //push all class name into this array
});
console.log(cls_array); //check array value
var cls_string = cls_array.join(", "); //convert array to a string
console.log(cls_string);
//copy all class names from console panel and do whatever you want to do....
//By JavaScript
//one way
anim = '';
document.querySelectorAll('.wrap').querySelectorAll('li').forEach(function(item,index){
var some = item.getAttribute('data-animation');
anim += "'"+some+"' => __('"+some+"', 'text-domain'),\n";
})
anim;
//second way
anim = '';
document.querySelectorAll('.wrap').forEach(function(item,index){
var title = item.querySelector('h3').innerText;
anim += "'"+title+"' => [\n";
item.querySelectorAll('li').forEach(function(item,index){
var some = item.getAttribute('data-animation');
anim += "'"+some+"' => __('"+some+"', 'text-domain'),\n";
})
anim += "],\n";
})
anim;
var iconStringArray = '[';
Icons.forEach(function (item, key) {
iconStringArray += '"hm hm-'+item+'", ';
});
iconStringArray = iconStringArray.slice(0, -2) + ']';
iconStringArray;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment