Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding form fields with jQuery (contact 7 form in wordpress)

I´m trying to add form fields with jQuery (contact 7 form in wordpress). It has hidden fields that are shown with jQuery.

I just completed a jsFiddle that works fine: http://jsfiddle.net/Mangomeat/SfTyG/1/

My javascript:

$(document.body).click(function () {
    $("div:hidden:first").fadeIn("slow");
  });

But when I put the jQuery function into my wordpress test page, I can't get it to work.

http://libra-frisk.com/uberMenuTest/?page_id=84#

like image 211
Johny Avatar asked Oct 17 '25 07:10

Johny


1 Answers

You haven't attached the click event to the show or click here links. Add an id to them and the div you want to appear. Then change your JS to something like:

$(document).ready(function() {
 $('#show').click(function () {
    $("#hiddencontent").fadeIn("slow");
  });
});

So in that case you would add an id of show to the click here call to action and an ID of hidden content to your hidden content that you want to reveal. The reason for this is that you aren't being specific enough about what elements you want to interact with, div and body in your case aren't specific enough.

like image 154
BarryWalsh Avatar answered Oct 20 '25 07:10

BarryWalsh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!