我使用 IframeTracker jQuery 脚本,当单击具有 iframe 类 id 的 iframe 元素时会发出什么警报。我想在单击时重定向到 page.php?id=(div_class) 。我有这个代码:
jQuery(document).ready(function($){
// Other iframes (wrapped with .iframetrack)
$('.iframetrack iframe').iframeTracker({
blurCallback: function(){
$('<div class="alert alert-info">').html('Click on iframe : #' + this._overId).appendTo('#consoleDebug').delay(3000).fadeOut();
window.setTimeout(function() {
window.location.href = 'page.php?id=' + this._overId;
}, 4000);
},
overCallback: function(element){
this._overId = $(element).parents('.iframetrack').attr('id'); // Saving the iframe wrapper id
},
outCallback: function(element){
this._overId = null; // Reset hover iframe wrapper id
},
_overId: null
});
});
它重定向但没有 div 类名到 page.php?id=undefined 我认为“this._overId”是 div 的类名,但不起作用。
如何在重定向 id 中使用单击的 div 类名? (page.php?id=(clicked_div_class))
最佳答案
怎么样:
$("div").click(
function(){
var id=this.className;
window.location.href = 'page.php?id=' + id;
})
关于javascript - jQuery 重定向到 div 类名称页面 (IframeTracker.js),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37749884/