Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将多个id组合到一个事件jquery中_Php_Jquery - Fatal编程技术网

Php 将多个id组合到一个事件jquery中

Php 将多个id组合到一个事件jquery中,php,jquery,Php,Jquery,我有三个文本字段需要有一个jquery单击事件 $('#landline' OR '#mobile_number' OR '#alternate_number').click(function() { $(this).val(""); }); 我希望在用户单击id为landline或mobile_number或alternate_number的字段时实现此功能,该值将设置为null。但是这个代码不起作用 使用,连接多个选择器: $('#landline, #mobile_number, #al

我有三个文本字段需要有一个jquery单击事件

$('#landline' OR '#mobile_number' OR '#alternate_number').click(function()
{
$(this).val("");
});

我希望在用户单击id为landline或mobile_number或alternate_number的字段时实现此功能,该值将设置为null。但是这个代码不起作用

使用
连接多个选择器:

$('#landline, #mobile_number, #alternate_number').click(function() {
    $(this).val("");
});

你读过这些文件了吗?或者,您可以为所有元素分配同一个类。注释的hank已经解决了。谢谢谢谢!:)@MadId速度更快,因为jQuery将映射到本机getElementById(),我同意,但我们也应该考虑代码维护。我们不可能一直都有100%优化的代码:)是的,那很简单,谢谢!我从没想过会是这样,我已经找了一个小时了。哈哈,我是诺布。