[jQuery] Re: Difference with two ways to select elements?

2009-10-20 Thread Evgeny Bobovik

1: $(select[name^='start_me_']).val(0); - this method set value only
in first founded selector, second method is most optimal to do what
you want - this method found all elements matches your criteria.
   Gk___
Sent from Minsk, Belarus



2009/10/19 Morris Li morris...@gmail.com:

 Hi All

 I am having a question and seeking some help from the group.

 What I want to do? - to set the SELECTS that match the citerias to be
 defaul option.

 1: $(select[name^='start_me_']).val(0);
 2: $(select[name^='start_me_']).each(function() { this.value =
 0; });

 I found 1 doesn't work in IE but FF. Could someone let me konw why?
 And what's the difference between them?

 Many thanks
 Morris Li



[jQuery] Re: Difference with two ways to select elements?

2009-10-19 Thread waseem sabjee
ok, let me understand you clearly.
you want to change every option tag within a select to be a specific value ?
if the method you mentioned above does not work try this :

var obj = $(.myclass); // use jquery to select your SELECT by class
var opts = $(option, obj); // find all option tags within that select
opts.each(function(i) { // for each option tag - declare i for counting
 opts.eq(i).attr({ // change the current options attribute
  value:'my new value' // change the value attribute
 });
});

On Mon, Oct 19, 2009 at 12:47 PM, Morris Li morris...@gmail.com wrote:


 Hi All

 I am having a question and seeking some help from the group.

 What I want to do? - to set the SELECTS that match the citerias to be
 defaul option.

 1: $(select[name^='start_me_']).val(0);
 2: $(select[name^='start_me_']).each(function() { this.value =
 0; });

 I found 1 doesn't work in IE but FF. Could someone let me konw why?
 And what's the difference between them?

 Many thanks
 Morris Li