Home >Web Front-end >JS Tutorial >How to change P tag text value in jQuery
Below I will share with you a jQuery method for changing the text value of the P tag. It has a good reference value and I hope it will be helpful to everyone.
There is a P tag value in the Web front page,
<p id="p1" > 该用户名已被注册 </p>
I want to change the content of the P tag through jquery.
I used the val() attribute at the beginning and found that I could not achieve the goal.
val() can be used to change the input content similar to a text box.
After checking, use jQuery HTML operation to complete the operation.
Function | Description |
---|---|
$(selector).html(content) | Change the (inner) HTML of the selected element |
$(selector).append(content) | Append content to the (inner) HTML of the selected element |
$(selector).prepend(content) | "Prepend" content to the (internal) HTML of the selected element |
$(selector).after(content) | Add HTML after the selected element |
$(selector).before(content) | Add HTML before the selected element |
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
How to use the compile operation method in Vue
How to implement the dialog box in Vue
How to implement dynamic progress bar in D3.js
The above is the detailed content of How to change P tag text value in jQuery. For more information, please follow other related articles on the PHP Chinese website!