-
-
Save Yarov/3dba690c07d540c59574 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var config = { | |
"menu":[], | |
"widget":[] | |
}; | |
var setConfig =function(){ | |
$.each($('[data-type]'), function(index, data){ | |
if(data.dataset.type =="menu"){ | |
$(data).find('ul li').each(function(index, data){ | |
config.menu.push($(data).text()); | |
}); | |
} | |
else{ | |
var product = $(data).find('ul li').text(); | |
var widget = { | |
type:data.dataset.name, | |
product:product | |
} | |
config.widget.push(widget); | |
} | |
}); | |
console.log(config); | |
}; | |
$('.btn').on('click',function(e){ | |
e.preventDefault(); | |
setConfig(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment