I couldn't find this anywhere, partly because its keywords are pretty common.
$('.pause_button').text('<img src="../imgs/icons/control_pause_blue.png" alt="Resume" /> Resume');
How can this be printed as HTML and not convert the brackets and apostrophes?
Step 1: Firstly, we have to open that Html file in which we want to add the jQuery using CDN. Step 2: After then, we have to place the cursor between the head tag just before the title tag. And, then we have to use the <script> tag, which specify the src attribute for adding.
jQuery text() Method The text() method sets or returns the text content of the selected elements. When this method is used to return content, it returns the text content of all matched elements (HTML markup will be removed). When this method is used to set content, it overwrites the content of ALL matched elements.
The html() method in jQuery is used to get the contents of the first element in the set of matched elements or is used to set the HTML contents of every matched element. It returns the content of the first matched element. This function does not accept any arguments.
Make use of the .html
function avaialble in jQuery, .html()
.
For example:
$('div.demo-container').html('<p>All new content. <em>You bet!</em></p>');
In your case
$('.pause_button').html('<img src="../imgs/icons/control_pause_blue.png"
alt="Resume" /> Resume');
.text()
actually escapes all HTML specific characters, .html()
doesn't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With