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!
You forgot two things:
- Add a
http://
in front of the URL.
- 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");
});
});
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
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