jQuery-settings

Setting content - text(), html() and val()

We will use the same three methods from the previous chapter to set content:

text() - Sets or returns the text content of the selected element html() - Sets or returns the content of the selected element (including HTML tags) val() - Sets or returns the value of the form field

Below The example demonstrates how to set the content through the text(), html() and val() methods

Callback functions of text(), html() and val()

The three jQuery methods above: text(), html() and val() also have callback functions. The callback function takes two parameters: the index of the current element in the selected element list, and the original (old) value. Then return the string you wish to use as the function's new value.


Set attributes - attr()

jQuery attr() method is also used to set/change attribute values.

      

php中文网

点击按钮修改后,可以点击链接查看链接地址是否变化。

attr() method also allows you to set multiple attributes at the same time


attr() callback function

jQuery method attr() also provides a callback function. The callback function takes two parameters: the index of the current element in the selected element list, and the original (old) value. Then return the string you wish to use as the function's new value.


Continuing Learning
||

这是一个有 粗体 字的段落。

这是另外一个有 粗体 字的段落。

submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!