我希望能够替换空格,-但也想删除逗号和问号.我怎么能在一个函数中做到这一点?
到目前为止,我有它替换空格:
str_replace(" ","-",$title)
Run Code Online (Sandbox Code Playgroud) 我一直在寻找获得JSON数据的pinterest但是注意他们目前不会让你得到一个用户和一个特定的板,所以找到mashape我需要获得API密钥但使用头请求可以使用getJSON吗?目前的代码是:
我需要传递:"X-Mashape-Key:KEY_HERE"我看到它可以在ajax中完成,但不知道如何将getJSON重写为循环,但可以在这里看到:
http://blog.mashape.com/mashape-sample-code-executing-ajax-request-using-jquery/
$.getJSON(settings.apiPath + settings.username + '/boards/', function (data) {
beforeSend: setHeader,
console.log(data);
for (var i = 0; i < settings.count; i++) {
var feed = false;
if(data.data[i]) {
feed = data.data[i];
}
var temp_data = {
message: truncate(feed["message"], 100),
url: feed["link"]
};
$('#pinterestFeed ul').append('<li class="feed">' + templating(temp_data) + '</li>');
}
$(".pinterest #loading").hide();
});
Run Code Online (Sandbox Code Playgroud) 我需要为此添加另一个AND条件但是从另一个表中可以添加条件吗?
目前我的mysql查询是:
$category_min_price = db_get_field("SELECT min(price) FROM ?:product_prices p, ?:products_categories c WHERE p.product_id=c.product_id AND c.category_id = ?i",$category_id);
Run Code Online (Sandbox Code Playgroud)
但是我需要在上面的声明中检查产品是否处于活动状态,该声明位于另一个表中,详情如下:
table: ?:products
col: status
如果是分开的话 FROM ?:products WHERE product_id = "ID" AND status = "A"
任何人都知道如何将其合并到上面的查询中,因为它获得最低价格但获得了甚至禁用产品的最低价格,因此需要将该状态条件添加到仅执行活动产品
非常感谢先进!
我有以下jQuery当前在产品准备就绪时运行,但它正在做的是调整元素的高度,但看起来很丑,因为它在页面加载后改变高度所以我的问题是:是否可以加载代码和在显示之前设置高度?
$(document).ready(function () {
// set hero height to max viewport
var heroHeight = $(window).height();
var smsHeight = $('#send-text').height();
$('#oasis-hero').css('min-height', heroHeight - smsHeight - 140 + 'px');
// hide video
$('#hero-video').hide();
// click function to auto play video
$('.hero-text .primaryCta').on('click touchend', function (e) {
$("#hero-video")[0].src += "&autoplay=1";
$('#hero-video').show();
$('#hero-video-bg').hide();
$('.hero-text').hide();
$(this).unbind("click");
});
});
Run Code Online (Sandbox Code Playgroud) 我收到一个错误,并认为我知道为什么但不知道如何解决它....例如我的标签/ ID是:
shipping_address [country] <<我认为因为括号[]
我的JS是
$(document).ready(function() {
$("form :input").each(function(index, elem) {
var eId = $(elem).attr("id");
var label = null;
if (eId && (label = $(elem).parents("form").find("label[for="+eId+"]")).length == 1) {
$(elem).attr("placeholder", $(label).html());
$(label).remove();
}
});
});
Run Code Online (Sandbox Code Playgroud)
错误:
js__jquery.js?1419646 ...:1468未捕获错误:语法错误,无法识别的表达式:label [for = billing_address [first_name]]
示例HTML:
<div class="col-sm-6">
<div class="form-group">
<label for="card[first_name]">First Name<span> * </span></label>
<input id="card[first_name]" name="card[first_name]" type="text" class="form-control" value="" validate="true">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)