【问题标题】:jQuery: Modify the structure of an inputjQuery:修改输入的结构
【发布时间】:2014-08-24 11:48:08
【问题描述】:

我今天写了这篇文章,因为我需要一些关于 jquery 中一个简单函数的帮助,用于修改输入 [reCaptcha] 的结构并隐藏显示的图像。

包含 reCaptcha 插件的页面的代码是:

http://pastebin.com/Qahph2ZB

可以在 Jquery 中实现吗?

之前 ---------------------------------------------- --------------> 之后

>

(因为我看过一个脚本的视频[Made in Js/Jquery] 产生这种效果:-(

我试过了,但没有:-(

P.S:我无法修改页面的原始结构 :-( ...我想用 Greasemonkey 注入 Jquery。

提前致谢。

亲切的问候

卢卡。

【问题讨论】:

  • 但是代码很长,这里的格式不正确[我可以在 Pastebin 中发布但没有过期..] :-(

标签: javascript jquery input structure


【解决方案1】:

您可以使用 CSS 将 DIV 元素放置在文本和验证码的输入区域上吗?

在此处查看完整的源代码:http://gist.github.com/632560

如果您将代码(我正在使用第 1 页中的代码)修改为以下内容:

<div id="DivCaptcha">
    <!-- <span class="Instructions" id="Instructions">Fill the captcha.</span> -->
    <span class="Instructions" id="Instructions">Fill the captcha.</span>
    <form onsubmit="return submit();" action="">
    <div id="captcha-container">
        <script type='text/javascript'> var RecaptchaOptions = { theme : 'white' }; </script> <script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6LfF970SAAAAAFR6KJNsdJX6Itf43k_HWbxRcU4a "></script>
        <noscript>
            <iframe src="http://api.recaptcha.net/noscript?k=6LfF970SAAAAAFR6KJNsdJX6Itf43k_HWbxRcU4a " height="300" width="500" frameborder="0"></iframe><br/>
            <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
            <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
        </noscript>       
        <div id="cover-captcha">
        </div>      
        <div id="cover-input">
        </div>
    </div>
    <input type="submit" id="submit" value="Submit!">
</div>

然后您将以下 CSS 添加到您的页面:

#captcha-container {
    position:relative;
}
#cover-captcha {
    position:absolute;
    top:10px;
    left:10px;
    width:295px;
    height:55px;
    z-index:9999;
    background-color:#fff;
}
#cover-input {
    position:absolute;
    top:96px;
    left:26px;
    width:150px;
    height:20px;
    z-index:9999;
    background-color:#fff;
}

它将涵盖您想要涵盖的元素。然后,您可以在需要时使用 jQuery 显示/隐藏这些元素:

<input type="button" id="show-hide" value="Show/Hide Captcha fields"/>
<script>
    $("#show-hide").click(function(e){
        $("#cover-captcha, #cover-input").toggle();
    });
</script>

编辑:回应您的评论..试试这个:

$("#recaptcha_response_field").hide();
$("#recaptcha_image").hide();

【讨论】:

  • 我无法修改页面的原始结构 :-( ...我想用 Greasemonkey 注入 Jquery。
  • 哇,恭喜...再次感谢 :D :D
猜你喜欢
  • 2017-10-05
  • 2010-09-20
  • 1970-01-01
  • 1970-01-01
  • 2020-05-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多