I am pretty new to this awesome forum, therefore not sure if this question below belongs here.
A little JavaScript, which works perfect when I drop a static url in it but I can’t figure out how to do with get_permalink()
var $el, $tempDiv, $tempButton, divHeight = 0;
$.fn.middleBoxButton = function(text, url) {
return this.hover(function(e) {
$el = $(this).css("border-color", "white");
divHeight = $el.height() + parseInt($el.css("padding-top")) + parseInt($el.css("padding-bottom"));
$tempDiv = $("<div />", {
"class": "overlay rounded"
});
$tempButton = $("<a />", {
"text": text,
"href": url,
"class": "widget-button rounded",
"css": {
"top": (divHeight / 2) - 7 + "px"
}
}).appendTo($tempDiv);
$tempDiv.appendTo($el);
}, function(e) {
$el = $(this).css("border-color", "#999");
$(".overlay").fadeOut("fast", function() {
$(this).remove();
})
});
}
$(function() {
$(".widget-one").middleBoxButton("Read More", "http:// bla bla bla");
});
Any help I would love to get.
Probably the best way to do this is as suggested above by using wp_localize_script.
You haven’t mentioned how you’re including the javascript – but I’m going to assume you’re doing it the WordPress way. So, something like this:
now, the permalink will be accessible to your javascript via someUniqueName.myPermalink so…
the key bit of this is documented at: http://codex.wordpress.org/Function_Reference/wp_localize_script