How to grab a href value in a simplemodal call and pass the query string along?
I'm trying to get a php page to load in a simplemodal window, and to pass a query string along, something like
<a href="my_script.php?var1=value1&var2=value2" cla开发者_C百科ss="simple_modal">
What JS code would I need to load the href value of the clicked link into a simplemodal window (via an iframe or any other mean) ?
Something like this should work:
$('a.simple_modal').click(
function (e) {
e.preventDefault();
$.get(this.href, function(data) {
var resp = $('<div></div>').append(data); // wrap response
$(resp).modal();
});
}
);
UPDATE: You may need to wrap the response in a div for proper handling in jQuery (see above)
you can use the attr property to get the href value
$("a").attr("href")
$('.simple_modal').click(function() {
var hrefval= $(this).attr("href");
});
精彩评论