I'm fairly new to JQuery/JavaScript and I'm trying to refactor the following code:
$('#hour').click(function() {
$('#clockHours').slideToggle();
$('#clockMinutes').hide();
});
$('#minutes').click(function() {
$('#clockMinutes').slideToggle();
$('#clockHours').hide();
});
//print clicked onto views
$('.timeSelect').click(function() {
var text = $( this ).text();
$('#hourView').val( text );
});
$('.minuteSelect').click(function() {
var text = $( this ).text();
$('#minuteView').val( text );
});
I haven't had much luck figuring out this task. You may see what I want the refactored versionhow to do here un-refactoredimprove the code. Here is a codepenCodePen of the current working code and here's what I have done so far here refactoring codepenwhat I have tried.