安卓系统智能手机好吗?
我想买台智能手机安卓系统又不懂好不好
最满意答案
请参阅
event.data
。 数据不作为参数传递给处理程序,而是作为事件对象的属性传递:$("select#test").change({msg: "ok"}, function(event) { alert(event.data.msg); });
处理程序总是只接受一个参数,它是
event
对象。 这就是您的警报显示"[object Object]"
,您的功能正在打印事件对象。
如果你想使用自定义参数的函数,你必须将它们包装到另一个函数中:$("select#test").change({msg: "ok"}, function(event) { myHandler(event.data.msg); });
要不就
$("select#test").change(function(event) { myHandler("ok"); });
顺便说一句。 选择器最好写成
$('#test')
。 ID是(应该是)唯一的。 不需要预先标记标签名称。See
event.data
. The data is not passed as argument to handler, but as property of the event object:$("select#test").change({msg: "ok"}, function(event) { alert(event.data.msg); });
The handler always only accepts one argument, which is the
event
object. This is the reason why your alert shows"[object Object]"
, your function is printing the event object.
If you want to use functions with custom arguments, you have to wrap them into another function:$("select#test").change({msg: "ok"}, function(event) { myHandler(event.data.msg); });
or just
$("select#test").change(function(event) { myHandler("ok"); });
Btw. the selector is better written as
$('#test')
. IDs are (should be) unique. There is no need to prepend the tag name.
相关问答
更多-
如何使用jQuery的change()方法带参数的函数?(How to use a function that takes arguments with jQuery's change() method?)[2023-07-20]
请参阅event.data 。 数据不作为参数传递给处理程序,而是作为事件对象的属性传递: $("select#test").change({msg: "ok"}, function(event) { alert(event.data.msg); }); 处理程序总是只接受一个参数,它是event对象。 这就是您的警报显示"[object Object]" ,您的功能正在打印事件对象。 如果你想使用自定义参数的函数,你必须将它们包装到另一个函数中: $("select#test").change ... -
也许试试这段代码: char[] _symbols_ = { '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', ' ', '-', '+', '=', '~', '`', '\'', '\'', '{', '}', '[', ']', '\\', ':', ';', '<', '>', '?', '/', ',' }; List
symbols = new List (_symbols_); ... -
使用带有两个参数的函数实现JS本机'filter'方法(Implementing JS native 'filter' method with a function that takes two arguments)[2022-01-09]
要求您实现的filter()函数需要以某种方式构建一个通过测试的新数组值,然后返回该新数组。 这是使用现有each()方法的一种方法: var filter = function(collection, test) { var results = []; each(collection, function(val) { if (test(val)) { results.push(val); } }); return results; }; 然后,您可以按照在问题 ... -
方法'GetDeviceSelector'没有重载需要2个参数(No overload for method 'GetDeviceSelector' takes 2 arguments)[2023-05-05]
我改变了usntort为UInt16,它解决了System.ArgumentOutOfRangeException错误。 为此的解决方案 serialDevice = await SerialDevice.FromIdAsync(myDevices[0].Id); 返回null 正在改变变量serialDevice为serialPort一些恼人的原因... 编辑:它曾经工作过一次,它再次被打破....任何想法? 编辑2:有人给我解决方案 I changed the ushort to UInt16 wh ... -
经过IE7,8,9,opera,chrome,firefox和safari的测试。 在后台使用evil ,但如果必须重命名参数,我看不到任何其他方式。 (function(){ var decompileRE = /function\s*\([\s\S]*?\)\s*\{([\s\S]*)/, lastBrace = /\}[^}]*$/; window.SetArgumentList = function( fn, argNames ) { var match ...
-
Java - 重载方法需要接口参数。(Java - Overloaded method takes interfaces for arguments. Which method is called and why?)[2022-03-23]
原因是这样的,并且test(java.security.Key k)被调用是因为java.security.Key扩展了Serializable本身,因此java.security.Key比Serializable 更专用 ,并且更适用于方法调用。 The Reason this works and the test(java.security.Key k) is called is because java.security.Key extends Serializable itself, hence j ... -
通常认为最好的做法是不要改变输入,尽管没有任何东西阻止你这样做 - 这些参数就像过程中的变量一样被对待。 简而言之,您可以使用简单的功能。 但是如果你有一个更长,更复杂的功能,并坚持不改变输入,你的代码就变得更容易维护。 假设您从用户那里得到一个日期,但是您想要回到最后一个语句日期,该日期始终是上个月的最后一天。 你可以像这样操纵参数 Public Function LastStatementAmount(ByVal inputDate As Date) As Double Dim Return_ ...
-
您可以使用inspect.getargspec()来查看接受的参数以及关键字参数的任何默认值。 演示: >>> def foo(bar, baz, spam='eggs', **kw): pass ... >>> import inspect >>> inspect.getargspec(foo) ArgSpec(args=['bar', 'baz', 'spam'], varargs=None, keywords='kw', defaults=('eggs',)) >>> inspect.getargs ...
-
Jquery传递一个带参数的jquery方法作为函数的参数(Jquery pass a jquery method with arguments as function's parameter)[2022-07-21]
除非你使用eval否则你不能告诉javascript执行什么代码作为字符串,但是在评论中提到这不是很安全,通常不推荐。 然而,你可以做的是使你的loopTheChilds方法将一个函数作为参数,并且该函数有一个参数,该参数带有对元素的引用。 所以你最终可能会这样做: var childs = ["#foo", "#bar"]; loopTheChilds(function(elem) { elem.trigger('change'); }); loopTheChilds(function(ele ... -
numpy最多需要3个参数 - 一个解决这个问题的方法?(numpy where takes at most 3 arguments - a way around this?)[2024-02-04]
你的括号不平衡,在内部条件中你需要额外的括号: In [33]: b = np.where( np.logical_or(b < minimum , b > maximum) , b, ((np.where(apply_method == 'A',method_A(b), (np.where(apply_method == 'B',method_B(b),None)) )))) b Out[33]: array([1, 20, 3 ...