你可以告诉我当用户滚动到div的竞争对手时如何获取事件。 我有div有一些内容可争夺的竞争,如果用户滚动到顶部我想显示一个警告。 http://jsfiddle.net/d9584/
<div id="contend">Tendulkar (Listeni/ˌsətʃɪn tɛnˈduːlkər/; born 24 April 1973) is a former Indian cricketer widely acknowledged as the greatest batsman of the modern generation, popularly holds the title "God of Cricket" among his fans[2] He is also acknowledged as the greatest cricketer of all time.[6][7][8][9] He took up cricket at the age of eleven, made his Test debut against Pakistan at the age of sixteen, and went on to represent Mumbai domestically and India internationally for close to twenty-four years. He is the only player to have scored one hundred international centuries, the first batsman to score a Double Century in a One Day International, and the only player to complete more than 30,000 runs in international cricket.[10] In October 2013, he became the 16th player and first Indian to aggregate 50,000 runs in all recognised cricket (First-class, List A and Twenty20 combined).[11][12][13]
In 2002, Wisden Cricketers' Almanack ranked him the second greatest Test batsman of all time, behind Don Bradman, and the second greatest ODI batsman of all time, behind Viv Richards.[14] Later in his career, Tendulkar was a part of the Indian team that won the 2011 World Cup, his first win in six World Cup appearances for India.[15] He had previously been named "Player of the Tournament" at the 2003 edition of the tournament, held in South Africa. In 2013, he was the only Indian cricketer included in an all-time Test World XI named to mark the 150th anniversary of Wisden Cricketers' Almanack.[16][17][18]
Tendulkar received the Arjuna Award in 1994 for outstanding sporting achievement, the Rajiv Gandhi Khel Ratna award in 1997, India's highest sporting honour, and the Padma Shri and Padma Vibhushan awards in 1999 and 2008, respectively, India's fourth and second highest civilian awards. After a few hours of his final match on 16 November 2013, the Prime Minister's Office announced the decision to award Bharat Ratna, India's highest civilian award.[19][20] With the scientist C. N. R. Rao, he was conferred the award on 4 February 2014 by President Pranab Mukherjee in a special ceremony in the Durbar Hall of the Rashtrapati Bhavan. He is the youngest recipient to date and the first ever sportsperson to receive the award.[21][22] He also won the 2010 Sir Garfield Sobers Trophy for cricketer of the year at the ICC awards.[23] In 2012, Tendulkar was nominated to Rajya Sabha, the upper house of the Parliament of India.[24] He was also the first sportsperson (and the first without an aviation background) to be awarded the honorary rank of Group Captain by the Indian Air Force.[25] In 2012, he was named an Honorary Member of the Order of Australia.[26]
In December 2012, Tendulkar announced his retirement from ODIs.[27] He retired from Twenty20 cricket in October 2013[28] and subsequently announced his retirement from all forms of cricket,[29] retiring on 16 November 2013 after playing his 200th and final Test match, against the West Indies in Mumbai's Wankhede Stadium.[30][31] Tendulkar played 664 international cricket matches in total, scoring 34,357 runs.[1</div>
答案 0 :(得分:5)
这是一个小提琴:http://jsfiddle.net/d9584/1/,不要忘记你的div实际上需要一个高度才能滚动。
然后你只需绑定scroll
事件并获得$(this).scrollTop()
答案 1 :(得分:0)
@crisbeto已经(jquery)$("#element").scrollTop()
或原生 document.getElementById("element").scrollTop
投掷一个我用于奇怪滚动元素的例子 - 有一些额外的ui 很有钱所以认为值得张贴
<强> http://jsfiddle.net/5Jz8A/ 强>
在标记中添加一类.content-scroller
要滚动的任何元素。
$(".content-scoller").on("scroll",function() {
_contentDiv = $(this);
_contentDiv.addClass("scrolling");
/* is it top ? */
if(_contentDiv.scrollTop() ===0) { _contentDiv.removeClass("nottop"); }
else { _contentDiv.addClass("nottop"); }
/* have we stopped scrolling ? */
clearTimeout($.data(this, 'this_timer'));
$.data(this, 'this_timer', setTimeout(function() {
_contentDiv.removeClass("scrolling"); }, 100));
});
* ^检查'已滚动停止'来自** @yckart's answer ****
的简洁速记