home

Jquery set() Method

Jquery set content method is used to replace current value of matched elements, including their descendants, there is another three methods previous pages to set content (if you want to change text in existing pages you can change using three methods like text(), html(), val()).

Jquery text() method cannot be used on form inputs or scripts. To set or get the text value of input or textarea elements, use the .val() method. To get the value of a script element, use the .html() method.

Jquery .text() Method

Below the html code it has five paragraphs here and first three paragraphs enclosed with div tag and every single paragraph has a b (b=bold text) tags. One button tag is there in the first line it has id called btn (id="btn").

<script>
  $("button").click(function(){
    $("#container1").text("Example of  .Text Method");
});
</script>

Jquery .html() Method

<script>
  $("button").click(function(){
     $("# container2").html("Example of .html");
});
</script>

Jquery .val() Method

<script>
  $("button").click(function(){
    $("# container3").val("Dolly Duck");
});
</script>