Skip to main content
edited tags; edited title; edited tags
Source Link
200_success
  • 145.7k
  • 22
  • 191
  • 481

Toggle functionfunctions for drop down for a clock time widget

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.

Toggle function for drop down

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 version to do here un-refactored codepen and here's what I have done so far here refactoring codepen.

Toggle functions for drop down for a clock time widget

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 how to improve the code. Here is a CodePen of the current working code and here's what I have tried.

Fix wrongly pasted indent.
Source Link
ferada
  • 11.4k
  • 26
  • 66

Toggle Functionfunction for drop down refactoring

I'm fairly new to JQuery/JavaScript

I am 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 out. You may see what I want the refactored version to do here un-refactored codepen and here's what I have done so far here refactoring codepen. Any tips would greatly be appreciated.

Thanks!

Toggle Function for drop down refactoring

I'm fairly new to JQuery/JavaScript

I am 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 this task out. You may see what I want the refactored version to do here un-refactored codepen and here's what I have done so far here refactoring codepen. Any tips would greatly be appreciated.

Thanks!

Toggle function for drop down

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 version to do here un-refactored codepen and here's what I have done so far here refactoring codepen.

added 1 character in body
Source Link

I'm fairly new to JQuery/JavaScript

I am 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 this task out. You may see what I want the refactored version to do here un-refactored codepenand and here's what I have done so far here refactoring codepen. Any tips would greatly be appreciated.

Thanks!

I'm fairly new to JQuery/JavaScript

I am 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 this task out. You may see what I want the refactored version to do here un-refactored codepenand here's what I have done so far here refactoring codepen. Any tips would greatly be appreciated.

Thanks!

I'm fairly new to JQuery/JavaScript

I am 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 this task out. You may see what I want the refactored version to do here un-refactored codepen and here's what I have done so far here refactoring codepen. Any tips would greatly be appreciated.

Thanks!

Source Link
Loading