0

I am working on a wordpress plugin written in jQuery. I want to add a div element right after the article ends. Right now, I am doing this in the following way:

$('div.entry-content').append('<div class="my-div"></div>');

Will this be universal for all wordpress blogs? Is there a better way to do this? Thanks!

1 Answer 1

2

I think this is fine. But better do it like-

jQuery('div.entry-content').append('<div class="my-div"></div>');

Cause the $ sign doesn't work some time with WordPress. Better if you wrap your jQuery code with this below code-

(function( $ ) {
    'use strict';

    // Write your jQuery code here.
    // And here you can use $ or jQuery as your wish.

})( jQuery );

Now about jQuery method, you can also use after() or insertAfter() to add something after the article tag.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.