如何使用jQuery设置按钮单击事件的位置? [英] How can I set location for a button on-click event using jQuery?

查看:102
本文介绍了如何使用jQuery设置按钮单击事件的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此页面:

链接

在首页上,您会找到一个名为获取报价"的按钮.当您单击此按钮时,我要打开链接"google.com".

Here on the homepage, you will find a button called "Get a quote". When you click on this button I want to open link "google.com".

我尝试使用此代码对jQuery进行此操作,但是它不起作用.

I tried to do this with jQuery using this code but it's not working.

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

此网站是由Wordpress制作的,我使用了插件联系表格7

This site is made with Wordpress and I used the plugin 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>

您能帮我解决这个问题吗?

Can you please help me to solve this problem?

提前谢谢!

推荐答案

您忘记了两件事:

  1. 在URL前面添加http://.
  2. wpcf7-submit更改为.wpcf7-submit.
  1. Add a http:// in front of the URL.
  2. Change wpcf7-submit to .wpcf7-submit.

使用这种方式:

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

这篇关于如何使用jQuery设置按钮单击事件的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆