2017-10-12 5 views
2

私はjQueryで現在照会されている要素を取得する方法は?例えば

<img class="fr-box-wrapper"></img> 
<img class="fr-box-wrapper"></img> 
<img class="fr-box-wrapper"></img> 
<img class="fr-box-wrapper"></img> 
<img class="fr-box-wrapper"></img> 
<img class="fr-box-wrapper"></img> 

を持っている場合は、今私は、各$('.fr-box-wrapper')の幅と高さを得るのですか

this.magnify.click(function(e){ 
    $('.fr-box-wrapper').attr({ 
    "origwidth": $(this).width(), // this is wrong 
    "origheight": $(this).height() // this is wrong 
    }).css({ 
    position: "fixed", 
    top: "0", 
    left: "0", 
    width: $(document).width(), 
    height: $(document).height(), 
    background: "white", 
    overflow: "auto" 
    }); 
}); 

のですか?

+0

ここで達成したいこと。これは何ですか? –

+0

こんにちは、あなたはそれぞれの$( 'fr-box-wrapper')の幅と高さを取得したいのですか、または特定のクリックされた要素の高さと幅を取得したいですか? – Kannan

答えて

2
$('.fr-box-wrapper').each(function(){ 
    $(this).attr({ 
    "origwidth": $(this).width(), 
    "origheight": $(this).height() 
    }).css({ 
    position: "fixed", 
    top: "0", 
    left: "0", 
    width: $(document).width(), 
    height: $(document).height(), 
    background: "white", 
    overflow: "auto" 
    }); 
}); 
関連する問題