Ricardo's last point is important. Quite often you can improve jQuery
code significantly by choosing convenient markup.
Thank you for all of the great replies. I am going to implement some
of this code now. As I mentioned before, It is always great to see how
others would do something. Especially when I am newer to jQuery.
On Dec 16, 8:40 am, Ricardo Tomasi wrote:
> I'd write it like this:
>
> $(document).ready(f
I'd write it like this:
$(document).ready(function(){
function hideOthers(){
var sel = $('div.'+ $(what).val() || 'city' );
$('div').not(sel).hide();
sel.show();
};
hideOthers('input:checked');
$('input').click(function(){
hideOthers(this);
$('select[id
It's interesting to know that $.map and $.grep can be used to a more
generalized approach to this problem. Issya, you should look at
Scott's code as it is extensible for future use. Definitely learned
something new today.
On Dec 15, 8:14 pm, Scott Sauyet wrote:
> issya wrote:
> > I recently made
Don't run functions that return the same result multiple times, run
them once and store the results in a variable. Example:
$(document).ready ()
{
var checkedVal = $('input:checked').val();
if (checkedVal = 'city')
{
//
}
}
If you need to run more than 1 operation o
issya wrote:
I recently made this small script and was thinking it is a bit long.
It works just fine, I was wondering if there is any way to make it
shorter or is this right? Thanks in advance for the help.
The previous suggestion, I think missed the point that you were only
selecting the fir
Thank you for the reply. It is always nice to see how experienced
people would write it. At the same time I get to learn some new
tricks.
Thanks again
On Dec 15, 7:28 pm, Kean wrote:
> Here's how I will code it.
>
> jQuery(function($)
> { // this means document.ready
>
> var optionDisplay = f
Here's how I will code it.
jQuery(function($)
{ // this means document.ready
var optionDisplay = function() {
var val = $("input:checked").val();
$(".city, .zip, .country").hide();
if (val.length > 0)
$("."+val).show();
else
$(".city").show();
$("#id_zip_code,
8 matches
Mail list logo