I am learning J query and building a small project to help to teach myself.
My code seems very long to do what would seem like simple tasks even thou everything works well. I seem to repeating alot of functions like:
$("#england").click(function () {
$('#englandTxt').hide();
$('#northernIrelandTxt').hide();
$('#walesTxt').hide();
$('#scotlandTxt').hide();
$('#irelandTxt').hide();
$('#onLoad').hide();
$("#englandTxt").fadeIn("slow");
});
how would i tidy this up effectively?
thxs!
Your code would benefit from using classes to identify groups of elements, rather than having to access them all individually. Although there are clever workarounds, I would recommend using classes for targeting similar items in a single operation.
Demo