所以我試圖鏈接到一個彈出窗口,
當我用getId = alert($(obj).attr("id"))
測試時,它顯示了id值;
但是當我將其更改爲getId = $(obj).attr('id')
時,該值變爲undefined
。
任何解決方案?
// Pop-up window
var windowObject;
var getId;
openPopup(this.id);
function openPopup(obj) {
$(document).ready(function() {
$('.all').click(function() {
getId = $(obj).attr('id');
//getId = alert($(obj).attr("id"));
});
});
windowObject = window.open("slideshow/" + getId + ".html", "popup", width = 800, height = 500 ");
}
你叫'openPopup(this.id);'那麼你基本上做到'$(this.id).attr( '身份證')' – adeneo
@ adeneo但當然!不要忘記然後執行'$(「#」+ $(this).attr(「id」))。first()[0] .id'來確保你得到這個東西的ID! –