SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2006
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jquery - changing button to an image

    is it possible to replace a jquery button with an image or text. Here's the code below:

    Code:
    <script>
    
    Javascript
    $(document).ready(function(){
      $(".test .hide").replaceWith( "<a href"#">Test</a>" ).click(function(){
        $(this).parents(".test").fadeOut("slow");
      });
    });
    
    html
    <div class="test">
    <button class="hide">Hide</button>
    <p>Test</p>
    </div>
    </script>
    Any help would be great.

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,890
    Mentioned
    210 Post(s)
    Tagged
    12 Thread(s)
    The main reason that the snippet you posted is not working is because of the double quotes in this:

    Code:
    "<a href"#">Test</a>"
    Change it to use single quotes and add an equals sign:

    Code:
    "<a href='#'>Test</a>"
    Does that help?


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
  •