Wednesday, December 2, 2015

jQuery Get Content – val() html() text()


SINTAX :
(selector).html()     (selector).html(value)     (selector).html(callback)
(selector).val()     (selector).val(value)     (selector).val(callback)
(selector).text()     (selector).text(value)     (selector).text(callback)


jQuery Get Content – val() html() text()


Allow the developer to manipulate , modify or fetch the element values :

val() >>>> returns the value of input tags
text()  >>>>> returns the innerText of an element
html()  >>>>>  returns the innerHtml of an element

An overload of both functions accepts a function to set the value, providing the current value of the element :
jQuery Get Content – val() html() text()



jQuery Get Content – val() html() text()

SAMPLE CODE :
<script>
   $(document).ready(function(){
    $("button").click(function(){
    $("input:text").val(function(index,current){
          return current + " new value";
      });
   });
  });
</script>

That’s all: enjoy HTML5!!!
by carmel schvartzman
עריכה: כרמל שוורצמן

No comments:

Post a Comment