html - 使用 JQuery 重定向

标签 html css

<分区>

我有这个页面

link

在此页面中,您会找到一个名为“获取报价”的按钮。当我单击此按钮时,我想转到 google.com。

为此,我尝试了以下代码。

jQuery(function($) {
    $(".wpcf7-form-control.wpcf7-submit").click(function() {
        window.location = "www.google.com/index.php?id=";
    });
});

不幸的是,当有人点击按钮时,链接会出现这种形式。

http://dgprint.dg-site.com/www.google.com/?id=

谁能告诉我为什么不工作?该站点是使用 Wordpress 插件制作的,并使用了“Contact form 7”

提前致谢!

编辑:

<div class="contact-frm">
        <div class="right">
            <?php echo do_shortcode('[contact-form-7 id="9" title="get a quote"]'); ?>
        </div>
    </div>

编辑2:

<p><input type="submit" value="get a quote" class="wpcf7-form-control wpcf7-submit"><img class="ajax-loader" src="http://dgprint.dg-site.com/wp-content/plugins/contact-form-7/images/ajax-loader.gif" alt="Sending ..." draggable="false" style="visibility: hidden;"></p>

最佳答案

这样使用:

jQuery(document).ready(function($) {
    $('.wpcf7-form-control .wpcf7-submit').click(function() {
        window.location = "http://www.google.com/index.php?id=" + $(this).attr("id");
// ------------------------------------------------------------^^^^
    });
});

关于html - 使用 JQuery 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30844416/

上一篇:html - 清除 :both not affecting columns correctly

下一篇:css - 我可以插入背景大小 : cover into the background shorthand?

相关文章:

javascript - 上传图像然后检查最大标准然后创建缩略图

javascript - 如何将CSS媒体查询应用于视频海报?

javascript - 为多个元素实现单个饼图菜单?

css - 当同一 HTML 出现在多个页面上时设置其样式的最佳策略

JavaScript:触发多个事件?

HTML/CSS - 使背景适合任何窗口大小

html - CSS 高度 :100% not working on Table inside Flexbox Child

浏览器之间的 CSS 问题

javascript - 增量 CSS 媒体查询

javascript - .htaccess文件不加载js和css