- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试添加选项卡,以便当单击它们时,它会显示不同的内容。但是,我收到 3 个控制台错误。两次是加载时,第三次是每次点击技术链接时。页面加载时出现的两个是:
Uncaught Syntaxerror: Unexpected token ILLEGAL
Uncaught TypeError: Cannot call method 'getcontext' of null
Uncaught referenceError: showTechnical is not defined
<小时/>
Javascript:
<script type="text/javascript">
function showTechnical()
{
document.getElementById('container123').value='
<div class="row" id="technical">
<div class="col-md-3">
<div class="checkbox">
<label><input type="checkbox" name="technical[]" value=settlement" />Settlement</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=tickets" />Tickets</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=c_tickets" />Complimentary Tickets</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=texes" />Texes</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=p_l_m" />Permits/Licenses/Certificates</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=merchandise" />Merchandise</div> <div class="checkbox">
<label><input type="checkbox" name="technical[]" value=special_regs" />Special Regulations</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=control_production" />Control of Production</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=duration_performance" />Duration Performance</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=support_talent" />Support Talent</div> </div>
<div class="col-md-3">
<div class="checkbox">
<label><input type="checkbox" name="technical[]" value=prod_office" />Production Office</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=dress_rooms" />Dressing Rooms</div> <div class="checkbox">
<label><input type="checkbox" name="technical[]" value=runner" />Runner</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=stage_size" />Stage Size</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=house_blacks" />House Blacks</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=barricade" />Barricade</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=foh_mix_position" />FOH Mix Position</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=dj_riser" />DJ Riser</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=dj_equip" />DJ Equipment</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=stagehands" />Stagehands</div> </div>
<div class="col-md-3">
<div class="checkbox">
<label><input type="checkbox" name="technical[]" value=foh_speaker_system" />FOH Speaker System</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=foh_console" />FOH Console</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=foh_effects" />FOH Effects</div> <div class="checkbox">
<label><input type="checkbox" name="technical[]" value=communication" />Communication</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=monitor_system" />Monitor System</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=monitor_wedges" />Monitor Wedges</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=wireless_mic" />Wireless Microphones</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=lighting_req" />Lighting Requirements</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=video_req" />Video Requirements</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=ground_transportation" />Ground Transportation</div>
</div>
<div class="col-md-3">
<div class="checkbox">
<label><input type="checkbox" name="technical[]" value=security_req" />Security Requirements</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=towels" />Towels</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=purchasers_p_r" />Purchasers Production Representative</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=equipment_placement" />Equipment Placement</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=sound_checks" />Sound Checks</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=power_req" />Power Requirements</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=parking" />Parking</div><div class="checkbox">
<label><input type="checkbox" name="technical[]" value=tour_bus_power" />Tour Bus Power</div> <input class="form-control btn btn-primary" type="submit" value="Next"> </div>
</div>';
};
</script>
然后,我将 div 称为几行以下:
<div id="container123">
<li><a href="#" onclick="showTechnical()">Technical</a></li>
最佳答案
您正在寻找的是innerHTML
或者在 jQuery 中,.html()
不幸的是,你不能像那样多行 JS 字符串,这也会破坏你的代码。
您必须:
添加尾随 \
对于每一行。但这太乏味了。
var string = "Some \
multiline \
string";
或者在一行中完成所有操作。但这太困惑了。
或者将您拥有的"template"放入 <script>
中其类型不是 text/javascript
这会阻止它被解析。 ID 并使用innerHTML 获取内容。干净多了。
<script type="text/template" id="myTemplate">
HTML in here
</script>
您可以使用以下方式检索它们
var contents = document.getElementById('myTemplate').innerHTML;
document.getElementById('container123').innerHTML = contents;
或者在 jQuery 中
var contents = $('#myTemplate');
$('#container123').html(contents);
关于javascript - Uncaught ReferenceError : showTechnical is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20591381/
描述:。在我的Vue 3和nuxt 3项目中,我使用VITEST进行测试。但我在运行测试时遇到了一个问题:。版本。以下是我的页面代码:。下面是我的测试myest.spec.ts:。以下是我的vites
你好吗?我正在研究带有 Ionic 3 教程的 Google map 。我已经完成了那里解释的一切,但是当项目启动时,出现了这个错误。我调查了很多,但没有任何效果。谢谢! Error: Uncaugh
我刚刚开始使用 Node.js 并尝试使用模块。我已经安装了 Node 和 npm,并确保一切顺利。我将在下面添加代码来向您展示我得到了什么。 我有两个 js 文件,它们在这里。 app.js: va
我是 Angularjs 的初学者,在理解模块和作用域方面有些困难。 我不断收到范围未定义的错误,但我不明白为什么。首先,我将 Controller 链接到我设置路由的位置,但是由于在单击提交按钮时调
我正在制作一个 HTML 模板引擎。 程序遍历 HTML,并找到 {{ }} 的所有实例。然后它会遍历计数器中的所有键,并用对 Controller 的引用替换变量名称的实例。 例如,如果我的 Con
在我的 React Native 应用程序中,我有一个 ProductScreen,其中导入两个文件来完成屏幕。 文件 1 (Products.js) 是我的产品列表 文件 2 (Data.js) 是
我有以下类(class): class ScheduledContent { constructor(knex) { this.knex = knex } ge
在以下代码中,obj.sayhello() 行意味着sayhello在 obj 的上下文/范围内执行。 str未在 var 中定义(通过 sayhello )方法。 JS 将在范围内查找变量,即在
我正在尝试使用字符串作为函数的一部分。 const import1 = require('./import1'); const import2 = require('./import2'); //on
var g = { lang: "ttt", l: function(){ console.log(lang); } } console.log(g.l());
$(document).ready(function(){ $('#name').val('Name1'); }); function clickMe(){ console.lo
我刚刚完成了 Meteor 包的开发。现在我想通过将它添加到新的 Meteor 应用程序来测试它: my_cool_package_name/package.js Package.on_use(fun
我在给定的 SSCCE 代码中收到以下错误: Error: ReferenceError: electron is not defined Source File: http://localhost/
我正在关注一个简单的 tut,它有望构建一个响应式 slider ,但是它一直告诉我控制台中有一个错误指向一个名为 advance() 的函数 这是 slider 的简单 html:
我正在尝试使用基于按钮点击的表格中的数据填充表格。我正在将数据传递到 javascript 函数中。 )" id="modifyEdu" class="btn btn-primary"
我需要能够检查一个变量是否存在(如果它没有分配给 {})而不在 javascript 中抛出错误。当我尝试这段代码时 if (a) {} 它抛出 Uncaught ReferenceError
我在设置中有一个 mochajs 测试文件和一个 javascript 代码文件,如下所示: /js/module/codefile.js /js/test/testfile.js codefile.
我正在尝试构建一个简单的 Bookmarklet,它将一些外部 Javascript 加载到页面中,目标是将像 Stackoverflow 那样的 Markdown 编辑器添加到另一个站点。我可以使用
我有一个基于 Django 的网络应用程序。我用 Scrapy Crawler抓取网页。目前,我的目标是能够使用 jQuery 和 AJAX 请求从网页内控制爬虫。 我的理论设置如下: 在网页上,我有
以下 JavaScript... if (eval('typeof admin_post_css_theme_dark-moon)=='function')) {/**/} ...触发以下错误消息..
我是一名优秀的程序员,十分优秀!