Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/406.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.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
Javascript 将js变量作为属性传递给jquery操作_Javascript_Jquery_Html - Fatal编程技术网

Javascript 将js变量作为属性传递给jquery操作

Javascript 将js变量作为属性传递给jquery操作,javascript,jquery,html,Javascript,Jquery,Html,如何将temp var传递到jquery函数中,如下所示 var temp="path.png" $('#mapfoto')。前置('') 在字符串连接中使用正确的引号位置: $('#mapfoto').prepend('<img id="theImg" src="http://path.gr/"+temp />') $('#mapfoto').prepend('<img id="theImg" src="http://path.gr/' + temp + '" />

如何将temp var传递到jquery函数中,如下所示

var temp="path.png"
$('#mapfoto')。前置('')

在字符串连接中使用正确的引号位置:

$('#mapfoto').prepend('<img id="theImg"  src="http://path.gr/"+temp />')
$('#mapfoto').prepend('<img id="theImg" src="http://path.gr/' + temp + '" />');
$('#mapfoto')。前置('';

在字符串连接中使用正确的引号位置:

$('#mapfoto').prepend('<img id="theImg"  src="http://path.gr/"+temp />')
$('#mapfoto').prepend('<img id="theImg" src="http://path.gr/' + temp + '" />');
$('#mapfoto')。前置('';
$('#mapfoto')。前置(''');
$('#mapfoto')。前置(''');