rd42
rd42

Reputation: 3594

jquery attr combine commands

I'm not having luck getting the syntax correct for combining these jquery lines. Can append be used with attr() or do these just need to be called separately or in the callback? It doesn't have to be append either, it's the only thing writing to that element, I just didn't know any other way of getting text in there.

$('#People').append(array.names[9]);
$('#People').attr({
    class: 'blueDescriptorBig'
});

Upvotes: 1

Views: 99

Answers (1)

Selvakumar Arumugam
Selvakumar Arumugam

Reputation: 79840

I am not sure if I understood correctly, but see below

$('#People')
  .append(array.names[9])
  .addClass('blueDescriptorBig'); //Should use addClass instead of .attr for class

Upvotes: 3

Related Questions