Search code examples
jqueryrating

Generate automatic unique id base on the blog title


I am using polldaddys rating script on my blog site. I am just wondering if it is possible to modify the script using jquery to automatically add a unique id base on the title of my blog post?

This is the polldaddys rating script

<div id="pd_rating_holder_6508144"></div>
<script type="text/javascript">
PDRTJS_settings_6508144 = {
        "id" : "6508144",
        "unique_id" : "",
        "title" : "",
        "permalink" : ""
};
</script>
<script type="text/javascript" src="http://i.polldaddy.com/ratings/rating.js"></script>

And my html:

<div class="headline">
<div><h1>This is my title</h1></div>
</div>
<div class="blogbody">
<div><p>The body content is here</p></div>
</div>

Solution

  • If you just want to get the title of your page then do this...

    PDRTJS_settings_6508144 = {
        "id" : "6508144",
        "unique_id" : $(".headline h1").text(),
        "title" : "",
        "permalink" : ""
    };