小编Ker*_*ill的帖子

jQuery - 从我点击的所有div中删除类

我有一些代码工作,当你点击swatch-wrapper div时,可以打开和关闭类"active".

但是我只想让其中一个 div 一次拥有活动课程.现在我可以点击它们全部,它们都会有活动的类.我不知道如何从所有其他div中删除该类,除了我刚刚点击的那个.

我试图使用.parent(),但它似乎没有工作/我不认为我正确使用它.

HTML

<div class="variation_form_section">
  <div class="select">
    <div class="swatch-wrapper"></div>
    <div class="swatch-wrapper"></div>
    <div class="swatch-wrapper"></div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

JS

<script>
$(document).ready(function(){
    $(".variation_form_section .select div").each(function() { 
      $(this).click(function() {
        if($(this).hasClass( "active" )){
            $(this).removeClass( "active" );
        }else{
            $(this).addClass( "active" );
        }
      });
    }); 
});
</script>
Run Code Online (Sandbox Code Playgroud)

html jquery

8
推荐指数
3
解决办法
2万
查看次数

在.js文件中执行PHP代码

我试图让一些PHP在.js文件中执行,但显然不知道如何正确地执行它.

基本上代码是在我的页面上添加一些HTML标签,我将其用于滑动联系表单.然而,联系表单本身是通过短代码在Wordpress中完成的.所以我试图让短代码在代码中工作,使表单滑出.

var phpTest = '<?php do_shortcode("[contact-form-7 id=\'1088\' title=\'Live Chat Form\']"); ?>';

// add feedback box
$this.html('<div id="fpi_feedback"><div id="fpi_title" class="rotate"><h2>'
    + thisSettings.title
    + '</h2></div><div id="fpi_content">'
    + phpTest
    + '</div></div>');
Run Code Online (Sandbox Code Playgroud)

如果我将变量"phpTest"更改为带有文本的常规字符串,它显示正常,我只是不确定如何在此实例中执行php.

php wordpress jquery

7
推荐指数
2
解决办法
3万
查看次数

jQuery Real Person-总是失败

无论我输入什么(甚至是正确的验证码),我总是会得到不匹配的输出。我试过回显值(如果您输入正确的代码,它们应该匹配)。而且我总是得到这样的东西:

6952304285049
-1247767175

这是我的代码(我还要做一些其他验证):

<?php
include 'Header.php';
include 'Database.php';
?>
<script type="text/javascript">
    $(function() {
        $('#defaultReal').realperson();
    });
</script>

<h1>Sign Up</h1>

<?php

if ($_POST){

    $username = $_POST['username'];
    $password = $_POST['password'];
    $check = '';

    //validate CAPTCHA
    function rpHash($value) { 
        $hash = 5381; 
        $value = strtoupper($value); 
        for($i = 0; $i < strlen($value); $i++) { 
        $hash = (($hash << 5) + $hash) + ord(substr($value, $i)); 
        } 
        return $hash; 
    } 
      if (rpHash($_POST['defaultReal']) == $_POST['defaultRealHash']) { ?>
        <p class="accepted">You have entered the "real person" value …
Run Code Online (Sandbox Code Playgroud)

javascript php validation jquery captcha

5
推荐指数
1
解决办法
4574
查看次数

在 Wordpress 中覆盖父主题功能

我正在为我的网站使用免费的“响应式”Wordpress 主题,并且是第一次使用子主题。

我需要在小部件标签下添加一个 div 标签<h3>,但标签所在的侧边栏功能存储在父功能中,我无法覆盖子主题中的功能。

这是我必须尝试删除父侧边栏功能,并重新添加我自己的功能,但它并没有删除侧边栏:

添加侧边栏的原始函数看起来与我的函数相同child_responsive_widgets_init(),但responsive_widgets_init()如果有帮助,则会调用它。

<?php

function child_responsive_widgets_init() {

    register_sidebar( array(
                          'name'          => __( 'Main Sidebar', 'responsive' ),
                          'description'   => __( 'Area 1 - sidebar.php - Displays on Default, Blog, Blog Excerpt page templates', 'responsive' ),
                          'id'            => 'main-sidebar',
                          'before_title'  => '<div class="widget-title"><h3>',
                          'after_title'   => '</h3><em>&nbsp;</em></div>',
                          'before_widget' => '<div id="%1$s" class="widget-wrapper %2$s">',
                          'after_widget'  => '</div>'
                      ) );
}
function remove_parent_widgets() {
    remove_action( 'widgets_init', 'responsive_widgets_init' );
}
add_action('init','remove_parent_widgets');

add_action( 'widgets_init', 'parent_unregister_sidebars' );
function …
Run Code Online (Sandbox Code Playgroud)

php wordpress

3
推荐指数
1
解决办法
1890
查看次数

标签 统计

jquery ×3

php ×3

wordpress ×2

captcha ×1

html ×1

javascript ×1

validation ×1