这是我的示例代码:
$(window).scroll(function () {
if ($(window).scrollTop() >= $(document).height() - $(window).height()) {
// Run code here...
}
});
Run Code Online (Sandbox Code Playgroud)
当用户滚动到页面底部时,我使用上面的代码来执行东西.相反,当用户滚动到特定元素(例如#content)的底部而不是整个文档时,如何执行代码.
谢谢.
我有一个酒吧,其中包括分享和社交图标.现在这个栏位于帖子标题下面,如下所示:
<div class="post" id="post-<?php the_ID(); ?>">
<div class="title">
<h1><?php the_title(); ?></h1>
</div>
<div class="sharelinks">
<ul>
<li><a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php the_permalink(); ?>" data-text="<?php the_title(); ?>" data-count="horizontal">Tweet</a></li>
<li><div class="fb-like" data-href="<?php the_permalink(); ?>" data-send="false" data-layout="button_count" data-show-faces="false" data-font="arial"></div></li>
<li><g:plusone size="medium" href="<?php the_permalink(); ?>/"></g:plusone></li>
<li><a href="http://pinterest.com/pin/create/button/?url=<?php echo urlencode(get_permalink($post->ID)); ?>&media=<?php echo urlencode(sofa_image_src('full')); ?>&description=<?php echo urlencode(get_the_title($post->ID)); ?>" class="pin-it-button" count-layout="horizontal">Pin It</a></li>
<li><su:badge layout="1"></su:badge></li>
</ul>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
那是我的HTML.而我对"sharelinks"的css是:
.sharelinks {
padding: 10px 20px;
background: #f1f1f1;
box-shadow: 0 1px #fff inset, 0 -1px #fff inset;
border-bottom: 1px solid #ddd;
position: …Run Code Online (Sandbox Code Playgroud) 我试图让我的代码从一组过滤器中接受多个选择,这是我到目前为止通过复选框和获取元素的结果.
Array (
[for-juniors] => product_category
[for-men] => product_category
[coats] => product_category
[for-women] => product_category
[7-diamonds] => brand )
Run Code Online (Sandbox Code Playgroud)
如您所见,传递了多个product_category.我需要知道一个函数或路由,以便能够将该格式转换为代码可以操作的格式.例如
array('product_category' => 'for-juniors','for-men','coats','for-women', 'brand' => '7-diamonds');
Run Code Online (Sandbox Code Playgroud)
我真的不知道从哪里开始我的阵列.该数组具有重复值"product_category"作为样本,它表示每个唯一的过滤器,键是此过滤器的选项.
任何提示都会有很大的帮助.
我是响应式网页设计的新手,并且对于使用哪些媒体查询和设备要定位的各种偏好感到困惑.有标准吗?我想定位iphone,ipads和热门设备?
我在网上发现了这个:
/* Smartphones (portrait and landscape) ----------- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
@media only screen and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
/* Styles …Run Code Online (Sandbox Code Playgroud) 我有相同类的div,但每个3都包含在父div中.我无法按照我想要的方式获取索引.对不起,任何人都可以帮助我将索引作为0到8之间的数字..当我点击任何元素时?尽管有父元素.
这是我的测试完整代码.
<div class="more-content">
<div class="post">post 1</div>
<div class="post">post 2</div>
<div class="post">post 3</div>
</div>
<div class="more-content">
<div class="post">post 4</div>
<div class="post">post 5</div>
<div class="post">post 6</div>
</div>
<div class="more-content">
<div class="post">post 7</div>
<div class="post">post 8</div>
<div class="post">post 9</div>
</div>
<script type="text/javascript">
$(function() {
// navigate posts with next/prev buttons
$(".post").click(function(){
alert($(this).index());
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
如果我点击我得到索引0,1,2 ..我认为因为每3项都包裹在父项?我是jquery的新手,任何帮助表示赞赏.我需要的是得到相同类的帖子索引..说帖子6 =索引5 ..等等
更新如果单击的元素是post div中的子锚点而不是post div,我如何获得相同的结果?
我使用此模式仅检查从0到任何数量字段的数字.如何使代码不允许012,010 ..等我的意思是起始零,但仍然允许0作为独立的数字.
0,1,10,1等等都可以,
但不允许012,005等
有没有这样做的模式?
这是我的代码,但它的问题,它删除0,即使它不是我想避免的数字领先.我想在我的字段中允许0作为独立数字.
$('.td-qnt input').live('change keyup blur', function(e) {
var re = /^[0-9]\d*$/;
var str = $(this).val();
$(this).val(str.replace(/^[ 0]/g,''));
if (re.test(str)){
var price = $(this).parent().parent().prev('td').html();
var realprice = price.replace(/[^0-9\.]/g,'');
var result = realprice * str;
var subtotal = result.toFixed(2);
$(this).parent().parent().next('td').html('$'+subtotal);
} else {
$(this).parent().parent().next('td').html('$0.00');
$(this).val('');
}
});
Run Code Online (Sandbox Code Playgroud) 有人可以告诉我一个关于为我的$ .ajax请求设置超时的实际示例,并在第一个请求超时的情况下重做整个请求,我已经阅读了文档并且没有得到它.我将不胜感激任何帮助.
这是我的$ .ajax请求.
$.ajax({
url: '<?php bloginfo('template_directory'); ?>/ajax/product.php',
type: 'get',
data: {product_id : product_id},
beforeSend: function(){
$('#details').html('<div class="loading"></div>');
},
success: function(data){
$('.iosSlider').fadeOut('fast');
thisprod.addClass('current');
$('#details').css({opacity: 0}).html(data).stop().animate({left: 0, opacity: 1}, 800);
}
});
return false;
Run Code Online (Sandbox Code Playgroud) 我正在使用如下所示的数组:
$pms = array(
'msg1' => array(
'status' => 'unread',
'subject' => 'bla bla'
),
'msg2' => array(
'status' => 'unread',
'subject' => 'test..'
),
'msg3' => array(
'status' => 'unread',
'subject' => 'moreee..'
)
);
Run Code Online (Sandbox Code Playgroud)
我想要实现的是能够选择'msg3',例如,将状态从'unread'更新为'read'并将其放回到数组中的位置.
怎么做?
我有一个显示如下计数的div:
如何将文本从0更改为任何单词,例如,当鼠标位于div上时,并在鼠标离开时恢复为0.
我尝试了这段代码,但它没有用.
$('.post-fav a').bind('mouseenter',function() {
var default_text = $(this).text();
$(this).css({'background-position' : 'left bottom', 'color' : '#1871a4'});
$(this).html('<?php _e('favorite','deluxe'); ?>');
});
$('.post-fav a').bind('mouseleave',function() {
$(this).css({'background-position' : 'left top', 'color' : '#666'});
$(this).text(default_text);
});
Run Code Online (Sandbox Code Playgroud)
默认文本是可变的,每个元素都有特定的计数,我需要在鼠标移动时存储初始计数.我不能在js中将其硬编码为0或任何其他计数.
我有这个脚本,当按下键盘上的"N"和"P"键时,它会触发滚动到next/prev.我的问题是当用户以任何形式(例如搜索字段,登录字段等)正常输入这些字母时,如何阻止这种情况发生,因为当我在表格中按n例如John时,它不会写N而是触发滚动功能.如何解决这种行为?
我的代码如下:
$(document).keydown(function (evt) {
if (evt.keyCode == 78) {
evt.preventDefault();
scrollToNew();
} else if (evt.keyCode == 80) {
evt.preventDefault();
scrollToLast();
}
});
Run Code Online (Sandbox Code Playgroud)
谢谢.
我遇到number_format问题.以下是我尝试使用它的方法:
当我尝试将其乘以数量时,它返回1.例如
1,200.00 * 2
Run Code Online (Sandbox Code Playgroud)
它返回1.我怎样才能返回2,400.00?
我错过了什么?谢谢
有没有办法围绕PHP数字,如100.50到101
或100.47到101,以便点后的任何内容都会向上舍入到下一个正数?
谢谢!