Element Manipulation

Attributes

.css(property)

Demonstration Box
Get
Set

Set:

$('.demo-box').css('backgroundColor','yellow');
$('.demo-box').css({
  textAlign: 'right', 
  borderLeftWidth: '5px'
});

.attr(attribute)

Demonstration Box
Get
Set

Set:

$('.demo-box').attr('title', 'This is a new title!');

.val()

Demonstration Box
Get
Set

Set:

$(':text').val('new value');
$('textarea').val('more in textarea');

.html()

Demonstration Box
Get
Set

Set:

$('.demo-box').html('<strong>This</strong> is <em>new</em> content.');

.text()

  • Demonstration
  • Box
Get
Set

Set:

$('.demo-box').text('<strong>This</strong> is <em>new</em> content.');

.addClass(class)

Demonstration Box
Trigger

.toggleClass(class)

Demonstration Box
Trigger

.width() / .height()

Demonstration Box
Get
Set

Set:

$('.demo-box').height(25).width(320);

.offset() / .position()

Demonstration Box
Get