`

各种小例子

 
阅读更多
1、加载页面后,直接跳转到想要的位置。
jQuery.fn.autoscroll = function(selector) {
	$('html,body').animate(
	    {scrollTop: $('.one').offset().top},
		500
	)
}
$('.one').autoscroll();


2、在一列li中,点击任何一个,得到相应的index值
$('li').click(function(){
	var index = $(this).prevAll().length; alert(index)
  });



3、找到一个已经被选中的option元素
$('#someElement').find('option:selected');


4、隐藏一个包含了某个值文本的元素:
$("p.value:contains('thetextvalue')").hide(); 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics