Note that there are some explanatory texts on larger screens.

plurals
  1. POHide upload button when image is present, Show when Image is gone?
    primarykey
    data
    text
    <p>This is such an easy question, but for the life of me cannot get my solution to work, I have fiddled for a while now and am coming up slightly short, I feel like an idiot.</p> <p><a href="http://jsfiddle.net/N8pCq/292/" rel="nofollow">http://jsfiddle.net/N8pCq/292/</a></p> <p>Ill get straight into the code</p> <p>JQuery:</p> <pre><code> $('#_moon_static_bg_status').on('change',function(){ var image_status =$('#test').hasClass('static_preview_image'), upload_button = $(".moon_upload_button"); if (image_status){ upload_button.hide(); } else { upload_button.show(); } }).trigger('change'); </code></pre> <p>Simply put I just want to show the upload button based on whether the class .static_preview_image exisits, this class contains the image, when a user closes the image the whole div is removed, so I figured calling for that class would be good for showing and hiding, because when its not there we show the upload, when the image is shown we hide the upload button.</p> <p>HTML:</p> <pre><code> &lt;div class="moon_media_status" id="_moon_static_bg_status"&gt; &lt;input type="button" value="Upload File" class="moon_upload_button button"&gt;&lt;/input&gt; &lt;a rel="_moon_static_bg" class="moon_remove_file_button" href="#"&gt;Remove Image&lt;/a&gt; &lt;div id="test" class="static_preview_image"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>when .moon_remove_file_button is clicked the div you see under it .static_preview_image is removed completely, when user uploads an image the div with .static_preview_image comes back, so naturally we would want to remove that button and only expose the close button...</p> <p>Thinking back I could see how the open source jQuery removes the .moon_remove_file_button and copy that, but since I wrote this up id like to see where I am making the brain fart mistake...</p> <p>Again here is the fiddle... <a href="http://jsfiddle.net/N8pCq/292/" rel="nofollow">http://jsfiddle.net/N8pCq/292/</a></p>
    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.
    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