Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.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/Javascript追加搜索表单时出现意外标记_Javascript_Jquery_Html_Wordpress - Fatal编程技术网

通过jQuery/Javascript追加搜索表单时出现意外标记

通过jQuery/Javascript追加搜索表单时出现意外标记,javascript,jquery,html,wordpress,Javascript,Jquery,Html,Wordpress,我试图在wordpress网站的导航栏中添加搜索表单。我必须通过在页脚小部件中的脚本标记中编写javascript来实现这一点,因为我无法编辑实际的源代码。但是,我在控制台中收到一个错误,指示未知语法错误:意外令牌非法。但是,我无法确定需要更改什么来更正此错误 下面是我编写的javascript,它在控制台中被标记: $mainNav.append("<li id='search'> <form role='search' method='get' class='search-

我试图在wordpress网站的导航栏中添加搜索表单。我必须通过在页脚小部件中的脚本标记中编写javascript来实现这一点,因为我无法编辑实际的源代码。但是,我在控制台中收到一个错误,指示
未知语法错误:意外令牌非法
。但是,我无法确定需要更改什么来更正此错误

下面是我编写的javascript,它在控制台中被标记:

$mainNav.append("<li id='search'>
<form role='search' method='get' class='search-form form-inline' action='https://son.sites.unc.edu/'>
<div class='input-group'>
 <label class='hide'>Search for:</label>
  <input type="search" aria-labelledby='search site' value='' name='s' class='search-field form-control' placeholder='Search this site...'>
    <span class='input-group-btn'>
     <button type='submit' aria-labelledby='Submit' value='Submit Search' class='search-submit btn btn-default'>
      <span class='glyphicon glyphicon-search'>
      </span>
     </button>
    </span>
   </div>
</form></li>");
$mainNav.append(”;

Alex K.为我解决了这个问题:


type=“search”
应该是
type=“search”
一样清晰(整个字符串需要在一行上)

type=“search”
应该是
type=“search”
一样清晰(整个字符串需要在一行上)哦,太酷了,我没有想到。谢谢,我现在开始工作了。