0

I have this page:

link

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".

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=";
    });
});

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?

Thanks in advance!

1
  • 1
    maybe $('.wpcf7-form-control .wpcf7-submit')? Commented Jun 15, 2015 at 9:56

3 Answers 3

4

You forgot two things:

  1. Add a http:// in front of the URL.
  2. Change wpcf7-submit to .wpcf7-submit.

Use this way:

jQuery(document).ready(function($) {
    $('.wpcf7-form-control .wpcf7-submit').click(function() {
        window.location = "http://www.google.com/index.php?id=" + $(this).attr("id");
    });
});
Sign up to request clarification or add additional context in comments.

1 Comment

I added this code but do not understand why not go now ... if I click on the button does not change anything
0

use the below code:

window.location = "http://www.google.com/index.php?id=";

adding http:// before the link can help you.

Also use:

$('.wpcf7-form-control .wpcf7-submit');

if wpcf7-submit is class specify it using dot . in jQuery

if wpcf7-submit is id then specify it using dot # in jQuery

Comments

0

Instead of this :

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

Use this :

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

It will work for you. There is something you should know:

  • In jquery selector you should write two classas without space
  • $ doesn't work in wordpress, For more information see here

2 Comments

I added this code but do not understand why not go now ... if I click on the button does not change anything
@Gigi Do you add this code inside of (document).ready()? I will update my answer, wait a second

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.