Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery common loading image for all divs
    primarykey
    data
    text
    <p>I am trying to use the code bellow to reveal a div that contains a loading image for all divs but I cannot make it work.</p> <p>For example I have 4 divs and inside those divs I have included the div that holds the image loading icon. Each div has a button with same class name. Every time that I press the button the div that holds the loading image appears only in the first div.</p> <p>P.S I want to keep this structure because I am grabbing some attributes from <code>&lt;a href&gt;</code></p> <p>My Jquery Code:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $(".mybutton").click(function() { var id = $(this).attr("id"); var title = $(this).attr("title"); var dataString = 'id='+ id; $('#myloader').fadeIn("fast"); $.ajax({ type: "POST", url: "getvars.php", data: dataString, cache: false, success: function(html) { $('#myloader').fadeOut("fast"); } }); }); }); &lt;/script&gt; </code></pre> <p>And my html Code:</p> <pre><code>&lt;!-- Div 1 --&gt; &lt;div id="Master" style="width:100px; height:100px;"&gt; &lt;div id="myloader" style="width:50px; height:50px; display:none;"&gt;Wait...&lt;/div&gt; &lt;a href="" class="mybutton" id="someid" title="sometitle"&gt;Press me&lt;/a&gt; &lt;/div&gt; &lt;!-- Div 2 --&gt; &lt;div id="Master" style="width:100px; height:100px;"&gt; &lt;div id="myloader" style="width:50px; height:50px; display:none;"&gt;Wait...&lt;/div&gt; &lt;a href="" class="mybutton" id="someid" title="sometitle"&gt;Press me&lt;/a&gt; &lt;/div&gt; </code></pre>
    singulars
    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.
    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