Note that there are some explanatory texts on larger screens.

plurals
  1. POSimulating a click doesn't work... jQuery
    primarykey
    data
    text
    <p>I am trying to simulate a click with jquery if the class of a td is "nee". Somehow all options like trigger, and a document ready click wont work... </p> <p>HTML:</p> <pre><code>&lt;td align="center" class="one nee"&gt; &lt;img class="img-swap" src="images/nee.png" alt="Aanwezigheid"/&gt; &lt;/td&gt; </code></pre> <p>Trigger action:</p> <pre><code> $(document).ready(function(){ $('#some-id').trigger('click'); }); </code></pre> <p>The image that the HTML returns is a variable, standard value is "ja.png". But as soon as the item is set to no in the database, the image changes to nee.png. But when that is triggered, i want input fields to appear, the same way as they appear when i click ja.png to change to nee.png. wich is with a fade in. seperately it works. But i cant get the click to be simulated..</p> <p>image changeing code:</p> <pre><code> $(document).ready(function(){ $(".img-swap").click("click", function() { if ($(this).attr("class") == "img-swap") { this.src = this.src.replace("ja","nee"); } else { this.src = this.src.replace("nee","ja"); } $(this).toggleClass("ja"); }); }); </code></pre> <p>Code for fadein actions:</p> <pre><code> $(document).ready(function(){ $(".nee").trigger("click"); $("td.one").click("click", function(){ if ($(this).parent().find("td.two, td.three").hasClass("toggled")){ $(this).parent().find("td.two").fadeOut(400); $(this).parent().find("td.three").fadeOut(400); $(this).parent().find("td.two").removeClass("toggled"); $(this).parent().find("td.three").removeClass("toggled"); } else { if ($(this).parent().find("td.three").hasClass("DoNotWant")){ $(this).parent().find("td.three").fadeOut(400); $(this).parent().find("td.three").toggleClass("DoNotWant"); } else { $(this).parent().find("td.three").fadeIn(400); $(this).parent().find("td.three").toggleClass("toggled"); } $(this).parent().find("td.two").fadeIn(400); $(this).parent().find("td.two").toggleClass("toggled"); } }); $("td.two").click("click", function(){ if ($(this).parent().find("td.three").hasClass("toggled")){ $(this).parent().find("td.three").fadeOut(400); $(this).parent().find("td.three").removeClass("toggled"); $(this).parent().find("td.three").toggleClass("DoNotWant"); } else { $(this).parent().find("td.three").fadeIn(400); $(this).parent().find("td.three").toggleClass("toggled"); } }); }); </code></pre> <p>Anyone that can help me?</p> <p>Live example is here: <a href="http://bryan.limewebsolutions.nl/" rel="nofollow">http://bryan.limewebsolutions.nl/</a></p>
    singulars
    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