The best jQuery set the content and properties Tutorial In 2024, In this tutorial you can learn Set the content - text (), html () and val (),Examples,text (), html () and val () callback function,Examples,Set attributes - attr (),Examples,Examples,attr () callback function,Examples,
We will use the same method as in the previous chapter set three elements:
The following example demonstrates how text (), html () and val () method to set the content:
The above three jQuery methods: text (), html () and val (), also has a callback function. Callback by two parameters: the selected element in the list of elements under the current standard, as well as the original (old) value. Then the function returns the value you want to use the new string.
The following example shows text with a callback () and html ():
jQuery attr () method is used to set / change the property value.
The following example shows how to change the value (setting) link href attribute:
attr () method also allows you to set multiple properties simultaneously.
The following example shows how to set both href and title attribute:
Method jQuery attr (), also provide a callback function. Callback by two parameters: the selected element in the list of elements under the current standard, as well as the original (old) value. Then the function returns the value you want to use the new string.
The following example illustrates with a callback function attr () method: