I tried it, and this worked for me.

$(function(){

   $("div.OrderEntryListRow").not(".Selected").each(function(i){
       alert("before: " + $(this).attr("id"));
       $(this).attr("id", "Row_" + (i+1));
       $(this).html($(this).html() + ': ' + (i+1));
       alert("after: " + $(this).attr("id"));
   });

});

<div class="OrderEntryListRow">1</div>
<div class="OrderEntryListRow">2</div>
<div class="OrderEntryListRow">3</div>
<div class="OrderEntryListRow">4</div>
<div class="OrderEntryListRow">5</div>
<div class="OrderEntryListRow Selected">Selected</div>
<div class="OrderEntryListRow selected">selected</div>

Btw, in xhtml you _have to_ use lowercase for tags and attributes.

Cheers!



On 1/4/07, Christopher Jordan <[EMAIL PROTECTED]> wrote:

 Hi folks,

I've got another simple question. Is this not how you set an element's
attribute?
[from inside an .each()]

$(this).attr("AttributeName", "Value");

I thought that worked... I thought it had worked for me in the past.

Is there any reason that this wouldn't work:

var i = 1;
$("div.OrderEntryListRow").not(".Selected").each(function(){
    alert("before: " + $(this).attr("ID"));
    $(this).attr("ID", "Row_" + i);
    alert("after: " + $(this).attr("ID"));
    i++;
});

In this sample code above, the before and after alerts are identical. Is
there something else I'm missing?

I think I've got the above idea correct, but wanted to get some different
eyes to look at it with me.

Thanks,
Chris

--
http://www.cjordan.info


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/





--
Joan Piedra || Frontend webdeveloper
http://joanpiedra.com/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to