Ergo:爲什麼不做這項工作?有人可以幫我在jquery中獲取div類嗎?
我想製作一個動畫功能,它必須根據其名稱更改css div的位置。 例如,產品1不需要更改其頂部位置,產品2就可以,產品3必須更多。
一直在這掙了幾個小時!
if($(this).attr("class") = "product1")
{
$(this).cssAnimate({height: '100%',marginBottom:'-350px'}, {duration: 400});
}
else if($(this).attr("class") = "product2")
{
$(this).cssAnimate({top:'-176px',height: '100%',marginBottom:'-350px'}, {duration: 400});
}
else if($(this).attr("class") = "product3")
{
$(this).cssAnimate({top:'-352px',height: '100%',marginBottom:'-350px'}, {duration: 400});
}
else
{
return false;
}
HTML在哪裏?另外,請檢查您的運算符:'='是Assignment,==='==='用於Equality。另外,如果有類似'' – 2013-02-23 00:59:55
'請考慮更改「top」的值,您可能需要['hasClass'](http://api.jquery.com/hasClass/)只檢索一次屬性的類,等等。這會使代碼和意圖更容易思考。 – 2013-02-23 01:03:46