我有这个功能,它来自于我在wordpress中使用的一个插件。
this.changeColor = function(element, hex, temp, colorLinking) {
console.log('hex',hex);
};我想触发它并传递一些参数。
$('#fancy-product-designer-' + productID + '').trigger('changeColor', [obj,'#ffffff',true,true]) ;但是参数不会通过change color函数传递。
控制台日志: hex - false
我该怎么做才能让参数通过呢?
提前谢谢。
你好,罗宾
发布于 2016-03-18 16:55:47
您可以尝试这样做:
$(".btn").on("changeColor", function(element, hex, temp, colorLinking,lastarg) {
console.log('element', element);
console.log('hex', hex);
console.log('temp', temp);
console.log('colorLinking', colorLinking);
console.log('lastarg', lastarg);
});
$(".btn").on("click", function(e) {
$(".btn").trigger('changeColor', [false, '#ffffff', true, true]);
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" value="test" class="btn" />

https://stackoverflow.com/questions/36079641
复制相似问题