我一直在寻找一个通知栏,就像这个站点上的通知栏,显示在顶部,通知用户有变化等.它应该具有关闭的能力.我能为jquery找到的就是这一个
有没有人有任何其他建议或建议?
我正在尝试在PHP脚本中添加一些错误检查.这样做是否有效:
if (!mkdir($dir, 0)) {
$res->success = false;
$res->error = 'Failed to create directory';
echo json_encode($res);
die;
}
Run Code Online (Sandbox Code Playgroud)
遇到这样的错误后有没有更好的方法退出脚本?
我正在使用rottentomatoes电影API和twitter的typeahead插件使用bootstrap 2.0.我已经能够整合API,但我遇到的问题是在每个keyup事件之后调用API.这一切都很好,但是我宁愿在一个小暂停之后拨打电话,让用户先输入几个字符.
这是我在keyup事件后调用API的当前代码:
var autocomplete = $('#searchinput').typeahead()
.on('keyup', function(ev){
ev.stopPropagation();
ev.preventDefault();
//filter out up/down, tab, enter, and escape keys
if( $.inArray(ev.keyCode,[40,38,9,13,27]) === -1 ){
var self = $(this);
//set typeahead source to empty
self.data('typeahead').source = [];
//active used so we aren't triggering duplicate keyup events
if( !self.data('active') && self.val().length > 0){
self.data('active', true);
//Do data request. Insert your own API logic here.
$.getJSON("http://api.rottentomatoes.com/api/public/v1.0/movies.json?callback=?&apikey=MY_API_KEY&page_limit=5",{
q: encodeURI($(this).val())
}, function(data) {
//set this to true when your callback executes
self.data('active',true);
//Filter out your …
Run Code Online (Sandbox Code Playgroud) 我发现这个模板演示了我对jquery砌体和图像布局的问题.看一下这个twitter bootstrap模板页面:
第一次加载页面时,所有图像都相互堆叠,直到页面刷新或重新调整大小为止.然后正确显示图像.
这是我的HTML和jQuery有同样的问题:
<div class="gallery-masonry masonry" style="position: relative; min-height:100px; height: auto;">
<div id="loading">Loading ...</div>
</div>
Run Code Online (Sandbox Code Playgroud)
$.post("functions/photo_functions.php", { f: 'getallphotos'}, function(data) {
$('#loading').hide();
if(data) {
$.each(data.images, function(i, image) {
var img_block = '<div class="item masonry-brick" style="position: absolute; top: 0px; left: 0px;">' +
'<a href="#" class="thumbnail"><img src="'+image.url+'" alt=""></a>' +
'<div class="actions">' +
'<a title="" href="#" class="tip-top" data-original-title="Edit"><i class="icon-pencil icon-white"></i></a>' +
'<a title="" href="#" class="tip-top" data-original-title="Remove"><i class="icon-remove icon-white"></i></a>' +
'</div>' +
'</div>';
$(".gallery-masonry").append(img_block);
});
$('.gallery-masonry').masonry({
itemSelector: …
Run Code Online (Sandbox Code Playgroud) 我正在遍历一个json数据数组,但需要在迭代之前删除第一个元素.如何删除初始元素?这是我到目前为止:
$.post('player_data.php', {method: 'getplayers', params: $('#players_search_form').serialize()}, function(data) {
if (data.success) {
// How do I remove the first element ?
$.each(data.urls, function() {
...
});
}
}, "json");
Run Code Online (Sandbox Code Playgroud) 有没有人有任何技巧来对齐页面上的这两个按钮?默认情况下,facebook like按钮的iframe版本显示在google plus按钮下方,反之亦然.是否有任何css技巧让它们保持内联?
这是我目前的尝试
<div style="float:left;width:100px;">
<!-- Place this tag where you want the +1 button to render -->
<g:plusone></g:plusone>
<!-- Place this tag after the last plusone tag -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</div>
<div style="float:left;width:auto;">
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fmy_site&layout=button_count&show_faces=false&width=350&action=like&font=lucida+grande&colorscheme=light&height=40" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:350px; height:30px;" allowTransparency="true"></iframe>
</div>
Run Code Online (Sandbox Code Playgroud) 我在列表中有几个项目,并希望通过应用一些CSS样式,可能是背景颜色等突出显示用户点击的项目.
我的HTML看起来像这样:
<ul class="thumbnails">
<li>
<a href="#" class="thumbnail">
<img class="giftthumb" src='thumb1.jpg' alt="">
<span class="gifttitle">Thumb1</span>
</a>
</li>
<li>
<a href="#" class="thumbnail">
<img class="giftthumb" src='thumb2.jpg' alt="">
<span class="gifttitle">Thumb3</span>
</a>
</li>
<li>
<a href="#" class="thumbnail">
<img class="giftthumb" src='thumb3.jpg' alt="">
<span class="gifttitle">Thumb3</span>
</a>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
jQUery检索所选项目:
$('.thumbnail').click(function(e) {
e.preventDefault();
???
})
Run Code Online (Sandbox Code Playgroud) 我正在进行jquery post调用:
var t1 = $("#form").serialize();
$.ajax({
type: "POST",
url: "save_test.php",
data: t1,
cache: false,
success: function(data){
if (data.st) {
alert("Success");
}
else if (data.error) {
alert("Error");
}
}
});
Run Code Online (Sandbox Code Playgroud)
我的PHP看起来像我的错误测试:
$res = new stdClass();
$res->error = 'ERROR SEEN';
echo json_encode($res);
exit();
Run Code Online (Sandbox Code Playgroud)
为什么我不能访问从PHP返回的json编码数据?我希望这会触发我的data.error警报.
我正在尝试连续执行这些removeClass调用.似乎没有使用removeClass的回调函数,所以有另一种方法来模拟这个吗?
$("#card1").removeClass('flip');
//wait for card1 flip to finish and then flip 2
$("#card2").removeClass('flip');
//wait for card2 flip to finish and then flip 3
$("#card3").removeClass('flip');
Run Code Online (Sandbox Code Playgroud) jquery ×9
javascript ×4
php ×3
html ×2
google-plus ×1
image ×1
json ×1
onkeyup ×1
removeclass ×1
tags ×1