-1

I have implemented this code on my site:

$('.feed-item').append('<p> This is paragraph element. </p>');

on this page here: Test

however the code isn't working, it is definitely there as I can see it in the page source however nothing is happening. Could someone tell me what I'm doing wrong

Mike
  • 1
  • 1

4 Answers4

2

Edit: I just noticed in your page jQuery is defined as jQuery and not as $.

In your page you have new lines in your string which causes the error. This:

$( document ).ready(function() {
    $('.feed-item').append('
<p> This is paragraph element. </p>
<p>');
});

should be:

jQuery( document ).ready(function() {
    jQuery('.feed-item').append('<p> This is paragraph element. </p>');
});
Danmoreng
  • 2,367
  • 1
  • 19
  • 32
0

This is beacuse the DOM is not loaded.

$( document ).ready(function() {
    $('.feed-item').append('<p> This is paragraph element. </p>');
});

or put it at the bottom on the page after the HTML.

<p> is also not valid in script.

Darren Willows
  • 2,053
  • 14
  • 21
0

Try doing this

 $('.feed-item').append('</p><p> This is paragraph element. </p><p>');
Arun G
  • 1,678
  • 15
  • 17
-2

please add this code snippet to footer.php before</html> tag and remove from your previous location

<script>
$('.feed-item').append('<p> This is paragraph element. </p>');
</script>
Karthick Kumar
  • 2,349
  • 1
  • 17
  • 30