I'm currently working on a pretty easy jQuery element. But I am still learning about jQuery so I thought maybe Stackoverflow can show me something I need to learn.
You can see the element here: http://jsfiddle.net/4UbRU/
When you click on a span it enters the value into the input. That works fine, but as you can see the js code is very big and there must be a better way to do this, but like I said I'm still learning.
Maybe someone can give me a pointer in the right direction.
ps, I supose I have to use a variable somewhere but can't really figure it out on my own.
addede the jQuery code.
jQuery(document).ready(function() {
$("#spanval1").click(function(){
$('#hourvalue').val($('#spanval1').text());
});
$("#spanval2").click(function(){
$('#hourvalue').val($('#spanval2').text());
});
$("#spanval3").click(function(){
$('#hourvalue').val($('#spanval3').text());
});
jQuery('.hour_dropdown').hide()
jQuery("#more").click(function() {
$('.hour_dropdown').fadeToggle(200);
});
});