clear content of the div tag by javascript

Discussion in 'JavaScript' started by dsimi, Aug 11, 2011.

  1. #1
    How to clear the contents of the div tag through javascript when click the close button?.

    This is the full code in header.
    
    <script type="text/javascript">
        jQuery(document).ready(function($) {
          $('a[rel*=facebox]').facebox({
            loading_image : 'loading.gif',
            close_image   : 'closelabel.gif'
          }) 
        })
      </script>
    
    Code (markup):
    Contents:
    
    <a href="#mobile" rel="facebox">
    <img src="mobile.png">
    </a>
    <div id="mobile" style="display:none;">
    Dynamic content by php code.
    </div>
    
    Code (markup):
     
    dsimi, Aug 11, 2011 IP
  2. astrazone

    astrazone Member

    Messages:
    358
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    33
    #2
    find the class that goes on the image and set up a click listener then $("#mobile").html("");
     
    astrazone, Aug 11, 2011 IP
  3. dsimi

    dsimi Member

    Messages:
    265
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    48
    #3
    Iam not expert in javascript. I have added like below

    
    <script type="text/javascript">
        jQuery(document).ready(function($) {
          $('a[rel*=facebox]').facebox({
            loading_image : 'loading.gif',
            close_image   : 'closelabel.gif'
    $("#mobile").html(""); 
          }) 
        })
      </script>
    
    Code (markup):
    Is it right?
     
    dsimi, Aug 12, 2011 IP
  4. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #4
    nope..

    it should be...
    
    <script type="text/javascript">
        jQuery(document).ready(function($) {
          $('a[rel*=facebox]').facebox({
            loading_image : 'loading.gif',
            close_image   : 'closelabel.gif' 
          });
          $("#mobile").html("");
        })
      </script>
    
    Code (markup):
     
    JohnnySchultz, Aug 12, 2011 IP
  5. dsimi

    dsimi Member

    Messages:
    265
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    48
    #5
    Iam getting blank display box with close image button.
     
    dsimi, Aug 12, 2011 IP