在我的联系表格7中,我有两个单选按钮,根据用户的选择显示和隐藏联系表单中的字段.

当您单击"手机"单选按钮时,脚本(JS不是jQuery)会确保隐藏电子邮件字段,并且仅显示电话字段.单击电子邮件单选按钮时,将显示电子邮件字段,并隐藏电话字段.那部分正如我希望的那样工作.
我遇到的问题是我无法弄清楚如何阻止隐藏字段被Contact Form 7验证.例如,如果客户想要输入他们的电话号码而不是他们的电子邮件,插件仍然会给出他们尝试提交时出错,因为电子邮件字段未填写.
这是代码 -
JS:
window.onload=radioCheck;
function radioCheck() {
if (document.getElementById('pcmPhone').checked) {
document.getElementById('client-phone').style.display = 'block';
document.getElementById('client-email').style.display = 'none';
document.getElementById('phone-input').setAttribute("aria-required", "true");
document.getElementById('email-input').setAttribute("aria-required", "false");
} else {
document.getElementById('client-phone').style.display = 'none';
document.getElementById('client-email').style.display = 'block';
document.getElementById('phone-input').setAttribute("aria-required", "false");
document.getElementById('email-input').setAttribute("aria-required", "true");
}
}
Run Code Online (Sandbox Code Playgroud)
HTML(有一些联系表格7短代码):
<div class="formFieldWrap">
Name:<br />
[text* client-name]
</div>
<div class="contactPref">
How would you like us to respond?
<br/>
<span class="wpcf7-form-control-wrap cpcm">
<span class="wpcf7-form-control wpcf7-radio" id="cpm">
<span class="wpcf7-list-item">
<input type="radio" id="pcmPhone" id="phone-input" name="cpcm" value="Phone Call" checked="checked" onclick="radioCheck();"/>
<span class="wpcf7-list-item-label">Phone Call</span>
</span> …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置一个Chrome扩展程序,它会使用inspect元素功能自动保存我对网站所做的更改.我们的想法是,您将能够对网站进行实时更改,而无需返回到ide以保存更改并重新上传所有内容.扩展名称为DevTools Autosave.我一直在遵循本网站的指示.我正在尝试在Mac上安装它.
我已经安装了node.js和扩展.当我到在其讲话的指示有关的命令,以在终端上运行的部分,我在前面有和没有的"命令"尝试"故宫安装-g自动保存"命令,但我总是得到这个错误:
Error: EACCES, permission denied
at Function.startup.resolveArgv0 (node.js:815:23)
at startup (node.js:58:13)
at node.js:906:3
npm ERR! autosave@1.0.3 install: `node ./scripts/install.js`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the autosave@1.0.3 install script.
npm ERR! This is most likely a problem with the autosave package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./scripts/install.js
npm ERR! You can get their info via:
npm ERR! npm …Run Code Online (Sandbox Code Playgroud) terminal google-chrome-extension node.js google-chrome-devtools
我只是想知道是否有人知道只使用一个div获得嵌入边框效果的方法?或者我必须使用两个?这就是我的意思:
我目前正在使用带边框的div,用div填充div.我必须在心理上跟踪哪些in_wraps与哪些out_wraps.我想在页面上的元素上看起来像这样:

而不是必须使用两个div并匹配它们.这是我正在使用的CSS:
.out_wrap_blk{
padding: 5px;
background: black;
float:left;
margin: 10px;
}
.out_wrap_gry{
padding: 5px;
background: #323232;
float:left;
margin: 10px;
}
.in_wrap_grn{
border: 1px solid #0CFF0E;
padding: 20px;
}
.in_wrap_blk{
border: 1px solid black;
padding: 20px;
}
Run Code Online (Sandbox Code Playgroud)
是否可以将其减少到一个元素,或者我必须坚持使用包裹在内部元素周围的外部元素?
这段代码有效......
$(document).ready(function(){
$('body').css('background','black');
});
Run Code Online (Sandbox Code Playgroud)
但是这段代码不......
$(document).ready(function(){
$('thumb_slider').css('background','black');
});
Run Code Online (Sandbox Code Playgroud)
^^^我在整个代码中唯一改变的是括号内的id属性.什么都没有改变.
我有一个带有id ="thumb_slider"的html元素标签,它里面有我可以在屏幕上看到的文本,但是当我引用一个html标签或id而不是正文时,我的jquery都没有.我在这做错了什么?
我试图理解从函数返回jquery中的值的正确方法.我已经检查了API以及其他问题,但我找不到正确的方法来执行此操作.我想要的只是一个返回的简单变量,所以我可以将它设置为全局变量.这是我得到的:
var a = 0, b, c;
var imgArr = [];
$(document).ready(function() { //populates array with images
var smooth = popArr();
alert(smooth);
}
function popArr(){
$("#thumb_slider").children().each(function(index, element) {
var newImg = $("<img />").attr({
src: this.src,
alt: 'space'
}).addClass(index == 0 ? "left_slot" : (index == 1 ? "middle_slot" : "right_slot"));
imgArr.push(newImg);
return imgArr; // This comes back as undefined.
});
}
Run Code Online (Sandbox Code Playgroud)
我的问题是为什么它返回undefined?我甚至应该在Jquery中使用"return"吗?
我正在努力学习如何构建自己的WordPress主题.我已经完成了一些教程,但我遇到了麻烦.我似乎无法弄清楚我做错了什么.当我在我的"home.php"所在的文件中使用我的页脚html时,它可以正常工作.当我尝试将它分开然后将页脚html放在"footer.php"中并使用"get_footer();" 功能,页脚根本没有出现,明显或在代码中......它不在那里.我想知道是否还有其他一些我忽略了让页脚工作的东西?如果没有那么当我将代码分成不同的主题部分/文件时,什么可能导致页脚不显示?
这是home.php的代码:
<?php
/*
Template Name: Front Page
*/
?>
<?php get_header(); ?>
<?php get_template_part('nav'); ?>
<div id="content"><!-- Start Content -->
<?php get_sidebar('left'); ?>
<div id="middle-column" class="grid_8"><!-- Main Content Begins Here -->
<?php if (have_posts()) : while (have_posts()) : the_post(); ?><!-- Start Loop -->
<div class="post">
<h2 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h2>
<div class="entrytext">
<?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>
</div>
</div>
<?php
endwhile;
else:
?>
<?php _e('This page does not appear to have been …Run Code Online (Sandbox Code Playgroud)