Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.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
可以将jQuery元素传递给jQuery选择器吗_Jquery - Fatal编程技术网

可以将jQuery元素传递给jQuery选择器吗

可以将jQuery元素传递给jQuery选择器吗,jquery,Jquery,我想编写一个通用javascript函数,它以ID或jquery元素作为参数 function common(ID_or_Element) { return $(ID_or_Element).val(); } 第一次呼叫 common("#elementID"); 第二次呼叫 $element = $("#elementID"); common($element) 上面的代码正在工作,但是可以在jQuery选择器中传递jQuery元素吗。在第二次调用中,im传递jQuery元素,而

我想编写一个通用javascript函数,它以ID或jquery元素作为参数

function common(ID_or_Element)
{
  return $(ID_or_Element).val();
}
第一次呼叫

  common("#elementID");
第二次呼叫

$element = $("#elementID");
common($element)

上面的代码正在工作,但是可以在jQuery选择器中传递jQuery元素吗。在第二次调用中,im传递jQuery元素,而公共函数将把它传递给jQuery选择器

Yes,传递元素Yes很好。没关系<代码>$(选择器)与
$($(选择器))