kampret
kampret

Reputation: 31

get link post use script 'data:post.url' blogger not work

I want to show URLs on my blog with javascript or jQuery, but it did not work.

My code:

$('.elementDIV').html("<a href='data:post.url'>Link</a>")

How to change it to work?

Upvotes: 1

Views: 212

Answers (2)

Undefitied
Undefitied

Reputation: 747

Try to wrap your code with ready function:

$(document).ready(function() {
    $('.elementDIV').html("<a href='data:post.url'>Link</a>");
});

Upvotes: 1

Ashkan Mobayen Khiabani
Ashkan Mobayen Khiabani

Reputation: 34152

Well as your script is in the head and the <div class="elementDIV"> </div> is in the body. when your code runs, the div hasn't loaded yet and doesn't exist. put your script somewhere after the div. the best place would be before closing the body tag:

<script type="text/javascript">
$('.elementDIV').html("<a href='data:post.url'>Link</a>")
</script>
</body>

Upvotes: 0

Related Questions