Home  >  Article  >  Web Front-end  >  How to change P tag text value in jQuery

How to change P tag text value in jQuery

亚连
亚连Original
2018-06-04 17:03:282900browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn