Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery hide() does not hide parent
    primarykey
    data
    text
    <p>JQuery still driving me mad... Here's the problem: I have a page where visitors can leave their email address by clicking on a link inside a div (id="contact").</p> <pre><code>&lt;div id="contact"&gt;&lt;a href=""&gt;vuoi lasciare un recapito?&lt;/a&gt;&lt;/div&gt; </code></pre> <p>Once clicked, the "contact" div loads a php form. The user types in his email address, then the address is checked, then inserted in the Database, etc... Usual business.</p> <pre><code>$(document).ready(function() { $('#contact a').click(function() { $('#contact').load('mailform.php'); return false; }); $('#contact').submit(function(){ var email = $('input[name=email]', '#submitmail').val(); var submit = $('input[name=submit]', '#submitmail').val(); $('#contact').load('mailform.php',{'email': email,'submit': submit}); return false; }); //the close button - start $(".cls").click(function(){ alert($(this).parent().html()); $(this).parent().hide(); }); //the close button - end }); </code></pre> <p>The pain comes when I want to add a "close" button or link, so the user can hide the form after or even before filling the form.</p> <pre><code>&lt;div id="submitmail"&gt; &lt;form action="#" method="post"&gt; &lt;fieldset&gt; &lt;p&gt;&lt;label for="email"&gt;&lt;?php echo $_SESSION['nome']; ?&gt;&lt;/label&gt;&lt;input type="text" name="email" /&gt;&lt;/p&gt; &lt;p class="submit"&gt;&lt;input type="submit" name="submit" value="inserisci" /&gt;&lt;/p&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;/div&gt; &lt;span class="cls"&gt;Chiudi&lt;/span&gt; </code></pre> <p>The link (and the "the close button" script) simply don't work. No alerts, no switches, no div disappearing... Nothing. Already tried <code>$('span.cls').click(function()</code> and <code>$('#cls').click(function()</code> (after switching the "span" with a "div" and the class with an ID) no clues. Just a link to click that does nothing. Firebug and IE dev toolbar don't even get into the function. Alternative solutions are welcome...</p> <p>Thank you!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload