This time I will bring you jQueryHow to get and modify the value in the P tag, jQuery gets and modifies the value in the P tagWhat are the precautions, here are the practical cases , let’s take a look.
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.
Use val()Attribute at the beginning, but found that the goal could not be achieved.
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) | To the (inner) of the selected element HTML append content |
$(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 |
I believe you have mastered the method after reading the case in this article, more exciting Please pay attention to other related articles on php Chinese website!
Recommended reading:
How to implement the toggle method in jQuery
How to implement jQuery+JSONP across domains
How to create an animation effect with jQuery that bounces when it hits the edge of the frame
The above is the detailed content of How to get and modify the value in the P tag with jQuery. For more information, please follow other related articles on the PHP Chinese website!