我需要复制一个数组并删除元素,但只能从第二个数组中删除?
例如:
var m1 = [ "a","b","c","d"];
var m2 = m1;
alert(m1+' and '+m2); // "a b c d" and "a b c d"
m2.splice(0,1); // b c d
alert(m1 + ' and ' + m2); // b c d and b c d
Run Code Online (Sandbox Code Playgroud)
所以每个数组中的第一个元素都被删除了,但是如何让第一个数组保持静态?
我创建了一个简单的类比表:
+----+-------+-------+
| id | sku_1 | sku_2 |
+----+-------+-------+
| 1 | a1 | abcd |
| 2 | a2 | a3 |
| 3 | a3 | a1 |
+----+-------+-------+
3 rows in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)
什么意思?这意味着具有物品的产品具有与物品abcd类似的物品a1,否则例如具有物品的产品具有与物品a3类似的物品a1.
如何以单篇文章递归获取此表中的所有产品?
我的解决方案是错的:
// Small Class to get analogs of products
class Analogs {
public function get_analogs($sku)
{
if (!$sku) return false;
$link = mysql_connect('localhost','','');
mysql_select_db('test');
$sku = mysql_real_escape_string($sku,$link);
$query = mysql_query("SELECT * FROM …Run Code Online (Sandbox Code Playgroud) 如何在init函数中单击滑动事件?我是插件开发的新手,所以我需要一点帮助?
我正在编码:
(function( $ ) {
var methods = {
init: function(){
return this.bind('click',methods.slide());
},
slide: function() {
alert('I\'m sliding');
// and lets the element color turns into green
return this.css('color','green');
}
};
$.fn.myPlugin = function( method ) {
if ( methods[method] ) {
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof method === 'object' || !method ) {
return methods.init.apply( this, arguments );
} else {
$.error( ' Method ' + method + ' doesn\'t …Run Code Online (Sandbox Code Playgroud) 例如: index.php?color=#c2c2c2
echo $_GET['color'];
Run Code Online (Sandbox Code Playgroud)
这可能行不通,怎么样?