0

以下のリンクからログインモーダルをダウンロードしました。http://www.alessioatzeni.com/blog/login-box-modal-dialog-window-with-css-and-jquery/

CSSにいくつかの変更を加えましたが、それだけです。

ボタンをクリックしたときにモーダル ウィンドウを起動する jQuery コードを次に示します。

$(document).ready(function() {
$('a.loginbutton').click(function() {

    // Getting the variable's value from a link 
    var loginBox = $(this).attr('href');

    //Fade in the Popup and add close button
    $(loginBox).fadeIn(300);
    $.fn.formLabels(); //Initialize form labels

    //Set the center alignment padding + border
    var popMargTop = ($(loginBox).height() + 24) / 2; 
    var popMargLeft = ($(loginBox).width() + 24) / 2; 

    $(loginBox).css({ 
        'margin-top' : -popMargTop,
        'margin-left' : -popMargLeft
    });

    // Add the mask to body
    $('body').append('<div id="mask"></div>');
    $('#mask').fadeIn(300);

    return false;
});

// When clicking on the button close or the mask layer the popup closed
$('a.close, #mask').live('click', function() { 
  $('#mask , .login-popup').fadeOut(300 , function() {
    $('#mask').remove();  
}); 
return false;
});
    });

基本的に、ページの読み込み時にこのモーダルを読み込む必要があります。私は jQuery をほとんど知らないので、プラグインをダウンロードした理由です。私は本当にこれが機能する必要があります。

私はすでにこのコードを書いた人に連絡を取ろうとしましたが、返事はありませんでした。

4

2 に答える 2

4
$('a.loginbutton').click();

その行を追加するだけで、ページの読み込み時にクリックイベントが実行されます。

于 2013-02-06T22:43:07.197 に答える
-1

コードは、モーダルをロードする前に、ユーザーがログインボタンをクリックするのを待っています。これを試して:

$(document).ready(function() {
//$('a.loginbutton').click(function() {

// Getting the variable's value from a link 
var loginBox = $(this).attr('href');

//Fade in the Popup and add close button
$(loginBox).fadeIn(300);
$.fn.formLabels(); //Initialize form labels

//Set the center alignment padding + border
var popMargTop = ($(loginBox).height() + 24) / 2; 
var popMargLeft = ($(loginBox).width() + 24) / 2; 

$(loginBox).css({ 
    'margin-top' : -popMargTop,
    'margin-left' : -popMargLeft
});

// Add the mask to body
$('body').append('<div id="mask"></div>');
$('#mask').fadeIn(300);

return false;
});
// When clicking on the button close or the mask layer the popup closed
$('a.close, #mask').live('click', function() { 
  $('#mask , .login-popup').fadeOut(300 , function() {
    $('#mask').remove();  
}); 
return false;
//});
});

.click()関数をコメントアウトしたと思います。

$(document).ready(function(){});内のすべて ページの読み込みが完了するとすぐに起動されます。

$('a.loginbutton')。click(function(){});内のすべて ユーザーがそのボタンをクリックしたときにのみ起動します。

于 2013-02-06T22:42:49.460 に答える