SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru etidd's Avatar
    Join Date
    May 2011
    Location
    atlanta, ga
    Posts
    632
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Smile Append 'Click to Exit' to H4 Element

    Hello all,

    For some reason, this line of code will not execute:

    Code JavaScript:
     $("#successfulsubmit h4").append('Click to Exit');

    It is within this block now, but I have tried it in other places...
    Code JavaScript:
    			setTimeout(function(){
    			  $("#successfulsubmit h4").append('Click to Exit');	
    		          $("#blackoverlay, #successfulsubmit").click(function(e){
    			     $("#blackoverlay, #successfulsubmit").remove();
    		           });

    This is the associated HTML:
    HTML Code:
        <div id="successfulsubmit">
        	<h3>&nbsp;</h3>
        	<p>&nbsp;</p>
            <h4>&nbsp;</h4>
        </div>
    It's on this page (emailbox.js).

    Is it simple to know why that append statement won't work when there are other .append() statements that work fine?

    Thanks all!

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,938
    Mentioned
    214 Post(s)
    Tagged
    12 Thread(s)
    Hi Tyler,

    If I look at the source of your page, the <div> with the id of "successfulsubmit" looks like this:

    HTML Code:
    <div id="successfulsubmit">
      <h3>&nbsp;</h3>
      <p>&nbsp;</p>
    </div>
    Try adding the <h4> tag to your HTML and see if that helps.

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by etidd View Post
    Is it simple to know why that append statement won't work when there are other .append() statements that work fine?
    Yes, it is simple to know why. It must be because the selection doesn't exist.

    #successfulsubmit exists, but there is no h4 element inside there.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    SitePoint Guru etidd's Avatar
    Join Date
    May 2011
    Location
    atlanta, ga
    Posts
    632
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)


    Oops, I thought I had uploaded those new files.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •