Jquery Set Content

Jquery text()

This helps to change or return the text content of selected element.

$(document).ready(function(){
 $('.link').click(function(){
  $('.test').text('Hello World.');
 });
});


Jquery html()

This helps to change or return the html content of selected element.

$(document).ready(function(){
 $('.link').click(function(){
  $('.test').text('Hello World.');
 });
});


Jquery val()

This helps to change or return the value of form field.

$(document).ready(function(){
 $('.link').click(function(){
  $('#input').val('Hello World.');
 });
});


Jquery attr()

This helps to change or return the href attribute in a link.

$(document).ready(function(){
 $('.link').click(function(){
  $('#youtube').attr('href', 'http://www.youtube.com');
 });
});

Share this

Related Posts