ah... and therein lies an important distinction.  I am not trying to
set HTML attributes on the tables - I am trying to set a property on a
JavaScript object that happens to correlate to a table in the DOM.
Forget the fact that it's tables - it could be any Javascript object.
For instance, the code I have now uses tables:

var tables = getElementsByTagName("table");
addTableProperties(tables);

function AddTableProperties(tables) {
    var tablesLength = tables.length;
    for (var i = 0; i != tablesLength; i++) {
        var table = tables[i];
        table.isHighlighted = false;
        table.highlightedRowIndex = 0;
      }
}

but it could just as easily be a "car" object:

function AddCarProperties(cars) {
    var carsLength= cars.length;
    for (var i = 0; i != carsLength; i++) {
        var car = car[i];
        car.isDiesel = false;
        car.numDoors = 4;
    }
}

and my ultimate goal is to have something like:

$("table").attr({isHighlighted: false, highlightedRowIndex: 0})

See what I mean?  I will read up on the data( ) function - thanks!

On Apr 7, 11:28 am, James <james.gp....@gmail.com> wrote:
> Also note that 'newProp1' and 'newProp2' are not valid HTML
> attributes. I'm not sure if you really have them existing on your HTML
> page.
>
> If possible, you might want to consider using jQuery's data() to get
> and set data associated with an element:http://docs.jquery.com/Core/data
>
> On Apr 7, 8:21 am, MorningZ <morni...@gmail.com> wrote:
>
>
>
> > You're close
>
> > $("table").attr({newProp1: "true", newProp2: "7"});
>
> > although to be honest, your selector or mine doesn't make all that
> > much sense since you would seemingly want to set unique properties on
> > each table, something neither line of code does
>
> > On Apr 7, 1:48 pm, Scott <william.scott.ba...@gmail.com> wrote:
>
> > > I want to add a property (not a class name or id) to all the tables in
> > > a web page.  I know I can use $("table") to get all the tables on the
> > > page - can I also do this:
>
> > >           $("table").each({newProp1:true, newProp2: 7});
>
> > > so that now table.newProp1 == true and table.newProp2 == 7 ???- Hide 
> > > quoted text -
>
> - Show quoted text -

Reply via email to